public function actionIndex() { if (isset($_GET['id'])) { $model = Document::model()->findByPk($_GET['id']); $this->render('detail', array('model' => $model)); } else { if ($_GET['type_id']) { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1 AND doc_group=\'service\' AND doc_type_id=' . $_GET['type_id']; $criteria->order = 'sort_order'; $total = Document::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(20); $pages->applyLimit($criteria); $model = Document::model()->findAll($criteria); $type = DocumentType::model()->findByPk($_GET['type_id']); $this->render('index', array('model' => $model, 'type' => $type, 'pages' => $pages)); } else { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1 AND doc_group=\'service\''; $criteria->order = 'sort_order'; $total = Document::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(20); $pages->applyLimit($criteria); $model = Document::model()->findAll($criteria); $this->render('index', array('model' => $model, 'pages' => $pages)); } } }
public function actionType($id) { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1 AND doc_type_id =' . $id; $criteria->order = 'sort_order ASC ,last_update DESC'; $model = Document::model()->findAll($criteria); $type = DocumentType::model()->findByPK($id); $this->render('index', array('model' => $model, 'type' => $type)); }
function do_main() { $this->oPage->setBreadcrumbDetails(_kt("bulk upload")); $oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/bulkUpload'); $add_fields = array(); $add_fields[] = new KTFileUploadWidget(_kt('Archive file'), _kt('The archive file containing the documents you wish to add to the document management system.'), 'file', "", $this->oPage, true, "file"); $aVocab = array('' => _kt('- Please select a document type -')); foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) { if (!$oDocumentType->getDisabled()) { $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); } } $fieldOptions = array("vocab" => $aVocab); $add_fields[] = new KTLookupWidget(_kt('Document Type'), _kt('Document Types, defined by the administrator, are used to categorise documents. Please select a Document Type from the list below.'), 'fDocumentTypeId', null, $this->oPage, true, "add-document-type", $fieldErrors, $fieldOptions); $fieldsets = array(); $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton(); $activesets = KTFieldset::getGenericFieldsets(); foreach ($activesets as $oFieldset) { $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace()); array_push($fieldsets, new $displayClass($oFieldset)); } // Implement an electronic signature for accessing the admin section, it will appear every 10 minutes global $default; $iFolderId = $this->oFolder->getId(); if ($default->enableESignatures) { $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true); $heading = _kt('You are attempting to perform a bulk upload'); $submit['type'] = 'button'; $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.bulk_upload', 'bulk', 'bulk_upload_form', 'submit', {$iFolderId});"; } else { $submit['type'] = 'submit'; $submit['onclick'] = ''; } $oTemplate->setData(array('context' => &$this, 'submit' => $submit, 'add_fields' => $add_fields, 'generic_fieldsets' => $fieldsets)); return $oTemplate->render(); }
<td> <input class='date-pick' id='effectiveDate' name='effectiveDate' style='width:80px' value='<?php echo $effectiveDate; ?> ' /> </td> </tr> <tr> <td style='text-align:right;vertical-align:top;'><label for="documentType" class="formText">Document Type:</label><br /><span id='span_error_documentTypeID' class='errorText'></span></td> <td> <span id='span_documentType'> <select name='documentTypeID' id='documentTypeID' style='width:185px;'> <?php $display = array(); $documentType = new DocumentType(); foreach ($documentType->allAsArray() as $display) { if ($document->documentTypeID == $display['documentTypeID']) { echo "<option value='" . $display['documentTypeID'] . "' selected>" . $display['shortName'] . "</option>"; } else { echo "<option value='" . $display['documentTypeID'] . "'>" . $display['shortName'] . "</option>"; } } ?> </select> </span> <br /> <span id='span_newDocumentType'><a href="javascript:newDocumentType();">add document type</a></span> <br /> </td> </tr>
public function actionSitemap() { $condition = new CDbCriteria(); $condition->condition = "news_type_id =2 AND status = 1"; $condition->order = "create_date desc,news_id desc"; $condition->offset = 0; $condition->limit = 6; $student_news = News::model()->findAll($condition); $news_criteria = new CDbCriteria(); $news_criteria->condition = "news_type_id =1 AND status = 1"; $news_criteria->order = "create_date desc,news_id desc"; $news_criteria->offset = 0; $news_criteria->limit = 3; $news = News::model()->findAll($news_criteria); $job_criteria = new CDbCriteria(); $job_criteria->condition = "news_type_id =3 AND status = 1"; $job_criteria->order = "create_date desc,news_id desc"; $job_criteria->offset = 0; $job_criteria->limit = 6; $job_news = News::model()->findAll($job_criteria); $pr_criteria = new CDbCriteria(); $pr_criteria->condition = "news_type_id =5 AND status = 1"; $pr_criteria->order = "create_date desc,news_id desc"; $pr_criteria->offset = 0; $pr_criteria->limit = 3; $newsInSide = News::model()->findAll($pr_criteria); $link_criteria = new CDbCriteria(); $link_criteria->condition = "status = 1"; $link_criteria->order = "sort_order"; $links = Link::model()->findAll($link_criteria); $criteria = new CDbCriteria(); $criteria->condition = "status = 1 AND doc_group ='download'"; $criteria->order = "sort_order"; $doc = DocumentType::model()->findAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "status = 1"; $criteria->order = "sort_order"; $org = Organization::model()->findAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "status = 1"; $criteria->order = "sort_order"; $report = ReportType::model()->findAll($criteria); $vdo_criteria = new CDbCriteria(); $vdo_criteria->condition = "page_id = 3 AND status = 1"; $vdo = Page::model()->find($vdo_criteria); // echo "<br> ===> "; // echo "<pre>"; // print_r($vdo); // echo "</pre>"; // exit; $this->render('sitemap', array('news' => $news, 'newsInSide' => $newsInSide, 'job' => $job_news, 'student_news' => $student_news, 'doc' => $doc, 'org' => $org, 'links' => $links, 'report' => $report, 'vdo' => $vdo)); }
} ?> href="<?php echo Yii::app()->createUrl('information'); ?> "><?php echo $admission; ?> </a> <ul> <?php $criteria = new CDbCriteria(); $criteria->condition = 'status=:status AND doc_group=\'service\''; $criteria->params = array(':status' => 1); $criteria->order = 'sort_order'; $doc_type = DocumentType::model()->findAll($criteria); foreach ($doc_type as $type) { ?> <li><a href="<?php echo Yii::app()->createUrl('information', array('type_id' => $type->doc_type_id)); ?> "><?php echo $type->name_th; ?> </a></li> <?php } ?> <!--li><a href="<?php echo Yii::app()->createUrl('admission'); ?>
function showForm($ID, $options = array()) { global $DB, $CFG_GLPI; $default_values = self::getDefaultValues(); // Get default values from posted values on reload form // On get because of tabs // we use REQUEST because method differ with layout (lefttab : GET, vsplit: POST) if (!isset($options['template_preview'])) { if (isset($_REQUEST)) { $values = Html::cleanPostForTextArea($_REQUEST); } } // Restore saved value or override with page parameter $saved = $this->restoreInput(); foreach ($default_values as $name => $value) { if (!isset($values[$name])) { if (isset($saved[$name])) { $values[$name] = $saved[$name]; } else { $values[$name] = $value; } } } if (isset($values['content'])) { // Clean new lines to be fix encoding $order = array('\\r', '\\n', "\\"); $replace = array("", "", ""); $values['content'] = str_replace($order, $replace, $values['content']); } if (isset($values['name'])) { $values['name'] = str_replace("\\", "", $values['name']); } if (!$ID) { // Override defaut values from projecttask if needed if (isset($options['_projecttasks_id'])) { $pt = new ProjectTask(); if ($pt->getFromDB($options['_projecttasks_id'])) { $values['name'] = $pt->getField('name'); $values['content'] = $pt->getField('name'); } } } // Check category / type validity if ($values['itilcategories_id']) { $cat = new ITILCategory(); if ($cat->getFromDB($values['itilcategories_id'])) { switch ($values['type']) { case self::INCIDENT_TYPE: if (!$cat->getField('is_incident')) { $values['itilcategories_id'] = 0; } break; case self::DEMAND_TYPE: if (!$cat->getField('is_request')) { $values['itilcategories_id'] = 0; } break; default: break; } } } // Default check if ($ID > 0) { $this->check($ID, READ); } else { // Create item $this->check(-1, CREATE, $values); } if (!$ID) { $this->userentities = array(); if ($values["_users_id_requester"]) { //Get all the user's entities $all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true); //For each user's entity, check if the technician which creates the ticket have access to it foreach ($all_entities as $tmp => $ID_entity) { if (Session::haveAccessToEntity($ID_entity)) { $this->userentities[] = $ID_entity; } } } $this->countentitiesforuser = count($this->userentities); if ($this->countentitiesforuser > 0 && !in_array($this->fields["entities_id"], $this->userentities)) { // If entity is not in the list of user's entities, // then use as default value the first value of the user's entites list $this->fields["entities_id"] = $this->userentities[0]; // Pass to values $values['entities_id'] = $this->userentities[0]; } } if ($values['type'] <= 0) { $values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE); } if (!isset($options['template_preview'])) { $options['template_preview'] = 0; } // Load ticket template if available : if ($ID) { $tt = $this->getTicketTemplateToUse($options['template_preview'], $this->fields['type'], $this->fields['itilcategories_id'], $this->fields['entities_id']); } else { $tt = $this->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']); } // Predefined fields from template : reset them if (isset($values['_predefined_fields'])) { $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']); } else { $values['_predefined_fields'] = array(); } // Store predefined fields to be able not to take into account on change template // Only manage predefined values on ticket creation $predefined_fields = array(); if (!$ID) { if (isset($tt->predefined) && count($tt->predefined)) { foreach ($tt->predefined as $predeffield => $predefvalue) { if (isset($default_values[$predeffield])) { // Is always default value : not set // Set if already predefined field // Set if ticket template change if (count($values['_predefined_fields']) == 0 && $values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID() || $predeffield == 'requesttypes_id' && empty($saved)) { // Load template data $values[$predeffield] = $predefvalue; $this->fields[$predeffield] = $predefvalue; $predefined_fields[$predeffield] = $predefvalue; } } } // All predefined override : add option to say predifined exists if (count($predefined_fields) == 0) { $predefined_fields['_all_predefined_override'] = 1; } } else { // No template load : reset predefined values if (count($values['_predefined_fields'])) { foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) { if ($values[$predeffield] == $predefvalue) { $values[$predeffield] = $default_values[$predeffield]; } } } } } // Put ticket template on $values for actors $values['_tickettemplate'] = $tt; $canupdate = Session::haveRight(self::$rightname, UPDATE); $canpriority = Session::haveRight(self::$rightname, self::CHANGEPRIORITY); $canstatus = $canupdate; if ($ID && in_array($this->fields['status'], $this->getClosedStatusArray())) { $canupdate = false; // No update for actors $values['_noupdate'] = true; } $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } if ($options['template_preview']) { // Add all values to fields of tickets for template preview foreach ($values as $key => $val) { if (!isset($this->fields[$key])) { $this->fields[$key] = $val; } } } // In percent $colsize1 = '13'; $colsize2 = '29'; $colsize3 = '13'; $colsize4 = '45'; $canupdate_descr = $canupdate || $this->fields['status'] == self::INCOMING && $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0; if (!$options['template_preview']) { echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>"; if (isset($options['_projecttasks_id'])) { echo "<input type='hidden' name='_projecttasks_id' value='" . $options['_projecttasks_id'] . "'>"; } } echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe' id='mainformtable'>"; // Optional line $ismultientities = Session::isMultiEntitiesMode(); echo "<tr class='headerRow responsive_hidden'>"; echo "<th colspan='4'>"; if ($ID) { $text = sprintf(__('%1$s - %2$s'), $this->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID)); if ($ismultientities) { $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id'])); } echo $text; } else { if ($ismultientities) { printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $this->fields['entities_id'])); } else { _e('New ticket'); } } echo "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>"; echo $tt->getBeginHiddenFieldText('date'); if (!$ID) { printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date')); } else { _e('Opening date'); } echo $tt->getEndHiddenFieldText('date'); echo "</th>"; echo "<td width='{$colsize2}%'>"; echo $tt->getBeginHiddenFieldValue('date'); $date = $this->fields["date"]; if ($canupdate) { Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false)); } else { echo Html::convDateTime($date); } echo $tt->getEndHiddenFieldValue('date', $this); echo "</td><td colspan='2'></td></tr>"; // SLTs echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('time_to_own'); if (!$ID) { printf(__('%1$s%2$s'), __('Time to own'), $tt->getMandatoryMark('time_to_own')); } else { _e('Time to own'); } echo $tt->getEndHiddenFieldText('time_to_own'); echo "</th>"; echo "<td width='{$colsize2}%' class='nopadding'>"; $slt = new SLT(); $slt->showSltForTicket($this, SLT::TTO, $tt, $canupdate); echo "</td>"; echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('due_date'); if (!$ID) { printf(__('%1$s%2$s'), __('Time to resolve'), $tt->getMandatoryMark('due_date')); } else { _e('Time to resolve'); } echo $tt->getEndHiddenFieldText('due_date'); echo "</th>"; echo "<td width='{$colsize4}%' class='nopadding'>"; $slt->showSltForTicket($this, SLT::TTR, $tt, $canupdate); echo "</td>"; echo "</tr>"; if ($ID) { echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('By') . "</th>"; echo "<td width='{$colsize2}%'>"; if ($canupdate) { User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); } else { echo getUserName($this->fields["users_id_recipient"], $showuserlink); } echo "</td>"; echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>"; echo "<td width='{$colsize4}%'>"; if ($this->fields['users_id_lastupdater'] > 0) { //TRANS: %1$s is the update date, %2$s is the last updater name printf(__('%1$s by %2$s'), Html::convDateTime($this->fields["date_mod"]), getUserName($this->fields["users_id_lastupdater"], $showuserlink)); } echo "</td>"; echo "</tr>"; } if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Resolution date') . "</th>"; echo "<td width='{$colsize2}%'>"; Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate)); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>"; echo "<td width='{$colsize4}%'>"; Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate)); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } if ($ID) { echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>"; echo "<td width='{$colsize2}%'>"; // Permit to set type when creating ticket without update right if ($canupdate || !$ID) { $opt = array('value' => $this->fields["type"]); /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'this.form.submit()'; } $rand = self::dropdownType('type', $opt); if ($ID) { $params = array('type' => '__VALUE__', 'entity_restrict' => $this->fields['entities_id'], 'value' => $this->fields['itilcategories_id'], 'currenttype' => $this->fields['type']); Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params); } } else { echo self::getTicketTypeName($this->fields["type"]); } echo "</td>"; echo "<th width='{$colsize3}%'>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</th>"; echo "<td width='{$colsize4}%'>"; // Permit to set category when creating ticket without update right if ($canupdate || !$ID || $canupdate_descr) { $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"]); if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { $opt['condition'] = "`is_helpdeskvisible`='1' AND "; } else { $opt['condition'] = ''; } /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'this.form.submit()'; } /// if category mandatory, no empty choice /// no empty choice is default value set on ticket creation, else yes if (($ID || $values['itilcategories_id']) && $tt->isMandatoryField("itilcategories_id") && $this->fields["itilcategories_id"] > 0) { $opt['display_emptychoice'] = false; } switch ($this->fields["type"]) { case self::INCIDENT_TYPE: $opt['condition'] .= "`is_incident`='1'"; break; case self::DEMAND_TYPE: $opt['condition'] .= "`is_request`='1'"; break; default: break; } echo "<span id='show_category_by_type'>"; ITILCategory::dropdown($opt); echo "</span>"; } else { echo Dropdown::getDropdownName("glpi_itilcategories", $this->fields["itilcategories_id"]); } echo "</td>"; echo "</tr>"; if (!$ID) { echo "</table>"; $this->showActorsPartForm($ID, $values); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('status'); printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status')); echo $tt->getEndHiddenFieldText('status') . "</th>"; echo "<td width='{$colsize2}%'>"; echo $tt->getBeginHiddenFieldValue('status'); if ($canstatus) { self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed')); TicketValidation::alertValidation($this, 'status'); } else { echo self::getStatus($this->fields["status"]); if (in_array($this->fields["status"], $this->getClosedStatusArray()) && $this->isAllowedStatus($this->fields['status'], Ticket::INCOMING)) { echo " <a class='vsubmit' href='" . $this->getLinkURL() . "&forcetab=TicketFollowup\$1&_openfollowup=1'>" . __('Reopen') . "</a>"; } } echo $tt->getEndHiddenFieldValue('status', $this); echo "</td>"; echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('requesttypes_id'); printf(__('%1$s%2$s'), __('Request source'), $tt->getMandatoryMark('requesttypes_id')); echo $tt->getEndHiddenFieldText('requesttypes_id') . "</th>"; echo "<td width='{$colsize4}%'>"; echo $tt->getBeginHiddenFieldValue('requesttypes_id'); if ($canupdate) { RequestType::dropdown(array('value' => $this->fields["requesttypes_id"], 'condition' => 'is_active = 1 AND is_ticketheader = 1')); } else { echo Dropdown::getDropdownName('glpi_requesttypes', $this->fields["requesttypes_id"]); echo Html::hidden('requesttypes_id', array('value' => $this->fields["requesttypes_id"])); } echo $tt->getEndHiddenFieldValue('requesttypes_id', $this); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('urgency'); printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')); echo $tt->getEndHiddenFieldText('urgency') . "</th>"; echo "<td>"; if ($canupdate && $canpriority || !$ID || $canupdate_descr) { // Only change during creation OR when allowed to change priority OR when user is the creator echo $tt->getBeginHiddenFieldValue('urgency'); $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"])); echo $tt->getEndHiddenFieldValue('urgency', $this); } else { $idurgency = "value_urgency" . mt_rand(); echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $this->fields["urgency"] . "'>"; echo $tt->getBeginHiddenFieldValue('urgency'); echo parent::getUrgencyName($this->fields["urgency"]); echo $tt->getEndHiddenFieldValue('urgency', $this); } echo "</td>"; // Display validation state echo "<th>"; if (!$ID) { echo $tt->getBeginHiddenFieldText('_add_validation'); printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation')); echo $tt->getEndHiddenFieldText('_add_validation'); } else { echo $tt->getBeginHiddenFieldText('global_validation'); _e('Approval'); echo $tt->getEndHiddenFieldText('global_validation'); } echo "</th>"; echo "<td>"; if (!$ID) { echo $tt->getBeginHiddenFieldValue('_add_validation'); $validation_right = ''; if ($values['type'] == self::INCIDENT_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT)) { $validation_right = 'validate_incident'; } if ($values['type'] == self::DEMAND_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) { $validation_right = 'validate_request'; } if (!empty($validation_right)) { echo "<input type='hidden' name='_add_validation' value='" . $values['_add_validation'] . "'>"; $params = array('name' => "users_id_validate", 'entity' => $this->fields['entities_id'], 'right' => $validation_right, 'users_id_validate' => $values['users_id_validate']); TicketValidation::dropdownValidator($params); } echo $tt->getEndHiddenFieldValue('_add_validation', $this); if ($tt->isPredefinedField('global_validation')) { echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>"; } } else { echo $tt->getBeginHiddenFieldValue('global_validation'); if (Session::haveRightsOr('ticketvalidation', TicketValidation::getCreateRights()) && $canupdate) { TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $this->fields['global_validation'])); } else { echo TicketValidation::getStatus($this->fields['global_validation']); } echo $tt->getEndHiddenFieldValue('global_validation', $this); } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('impact'); printf(__('%1$s%2$s'), __('Impact'), $tt->getMandatoryMark('impact')); echo $tt->getEndHiddenFieldText('impact') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('impact'); if ($canupdate) { $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"])); } else { $idimpact = "value_impact" . mt_rand(); echo "<input id='{$idimpact}' type='hidden' name='impact' value='" . $this->fields["impact"] . "'>"; echo parent::getImpactName($this->fields["impact"]); } echo $tt->getEndHiddenFieldValue('impact', $this); echo "</td>"; echo "<th>" . $tt->getBeginHiddenFieldText('locations_id'); printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id')); echo $tt->getEndHiddenFieldText('locations_id') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('locations_id'); if ($canupdate || !$ID) { Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $this->fields['entities_id'])); } else { echo Dropdown::getDropdownName('glpi_locations', $this->fields["locations_id"]); } echo $tt->getEndHiddenFieldValue('locations_id', $this); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('priority'); printf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority')); echo $tt->getEndHiddenFieldText('priority') . "</th>"; echo "<td>"; $idajax = 'change_priority_' . mt_rand(); if ($canpriority && !$tt->isHiddenField('priority')) { $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); $idpriority = 'dropdown_priority' . $idpriority; echo " <span id='{$idajax}' style='display:none'></span>"; } else { $idpriority = 0; echo $tt->getBeginHiddenFieldValue('priority'); echo "<span id='{$idajax}'>" . parent::getPriorityName($this->fields["priority"]) . "</span>"; echo $tt->getEndHiddenFieldValue('priority', $this); } if ($canupdate || $canupdate_descr) { $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); } echo "</td>"; echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('items_id'); printf(__('%1$s%2$s'), _n('Associated element', 'Associated elements', Session::getPluralNumber()), $tt->getMandatoryMark('items_id')); if ($ID && $canupdate) { echo " <a href='" . $this->getFormURL() . "?id=" . $ID . "&forcetab=Item_Ticket\$1'><img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'></a>"; } echo $tt->getEndHiddenFieldText('items_id'); echo "</th>"; if (!$ID) { echo "<td rowspan='2'>"; echo $tt->getBeginHiddenFieldValue('items_id'); $values['_canupdate'] = Session::haveRight('ticket', CREATE); if ($values['_canupdate']) { Item_Ticket::itemAddForm($this, $values); } echo $tt->getEndHiddenFieldValue('items_id', $this); echo "</td>"; } else { echo "<td>"; echo $tt->getBeginHiddenFieldValue('items_id'); $values['_canupdate'] = $canupdate || $canupdate_descr; Item_Ticket::itemAddForm($this, $values); echo $tt->getEndHiddenFieldValue('items_id', $this); echo "</td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Need comment right to add a followup with the actiontime if (!$ID && Session::haveRight('followup', TicketFollowup::ADDALLTICKET)) { echo "<th>" . $tt->getBeginHiddenFieldText('actiontime'); printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime')); echo $tt->getEndHiddenFieldText('actiontime') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('actiontime'); Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true)); echo $tt->getEndHiddenFieldValue('actiontime', $this); echo "</td>"; } echo "</tr>"; echo "</table>"; if ($ID) { $this->showActorsPartForm($ID, $values); } $view_linked_tickets = $ID || $canupdate; echo "<table class='tab_cadre_fixe' id='mainformtable4'>"; echo "<tr class='tab_bg_1'>"; echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('name'); printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name')); echo $tt->getEndHiddenFieldText('name') . "</th>"; echo "<td colspan='3'>"; if (!$ID || $canupdate_descr) { echo $tt->getBeginHiddenFieldValue('name'); echo "<input type='text' style='width:98%' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">"; echo $tt->getEndHiddenFieldValue('name', $this); } else { if (empty($this->fields["name"])) { _e('Without title'); } else { echo $this->fields["name"]; } } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('content'); printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')); if (!$ID || $canupdate_descr) { $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content'])); Html::showTooltip(nl2br(Html::Clean($content))); } echo $tt->getEndHiddenFieldText('content') . "</th>"; echo "<td colspan='3'>"; if (!$ID || $canupdate_descr) { // Admin =oui on autorise la modification de la description echo $tt->getBeginHiddenFieldValue('content'); $rand = mt_rand(); $rand_text = mt_rand(); $rows = 6; $content_id = "content{$rand}"; if ($CFG_GLPI["use_rich_text"]) { $this->fields["content"] = $this->setRichTextContent($content_id, $this->fields["content"], $rand); $rows = 10; } else { $this->fields["content"] = $this->setSimpleTextContent($this->fields["content"]); } echo "<div id='content{$rand_text}'>"; echo "<textarea id='{$content_id}' name='content' style='width:100%' rows='{$rows}'>" . $this->fields["content"] . "</textarea></div>"; echo Html::scriptBlock("\$(document).ready(function() { \$('#{$content_id}').autogrow(); });"); echo $tt->getEndHiddenFieldValue('content', $this); } else { $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content'])); echo nl2br(Html::Clean($content)); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; if ($view_linked_tickets) { echo "<th style='width:{$colsize1}%'>" . _n('Linked ticket', 'Linked tickets', Session::getPluralNumber()); $rand_linked_ticket = mt_rand(); if ($canupdate) { echo " "; echo "<img onClick=\"" . Html::jsShow("linkedticket{$rand_linked_ticket}") . "\"\n title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; } echo '</th>'; echo "<td colspan='3'>"; if ($canupdate) { echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>"; echo "<table class='tab_format' width='100%'><tr><td width='30%'>"; Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : ''); echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n"; echo "</td><td width='70%'>"; $linkparam = array('name' => '_link[tickets_id_2]', 'displaywith' => array('id')); if (isset($values["_link"])) { $linkparam['value'] = $values["_link"]['tickets_id_2']; } Ticket::dropdown($linkparam); echo "</td></tr></table>"; echo "</div>"; if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) { echo "<script language='javascript'>"; echo Html::jsShow("linkedticket{$rand_linked_ticket}"); echo "</script>"; } } Ticket_Ticket::displayLinkedTicketsTo($ID); echo "</td>"; } echo "</tr>"; // View files added echo "<tr class='tab_bg_1'>"; // Permit to add doc when creating a ticket echo "<th style='width:{$colsize1}%'>"; echo $tt->getBeginHiddenFieldText('_documents_id'); $doctitle = sprintf(__('File (%s)'), Document::getMaxUploadSize()); printf(__('%1$s%2$s'), $doctitle, $tt->getMandatoryMark('_documents_id')); // Do not show if hidden. if (!$tt->isHiddenField('_documents_id')) { DocumentType::showAvailableTypesLink(); } echo $tt->getEndHiddenFieldText('_documents_id'); echo "</th>"; echo "<td colspan='3'>"; // Do not set values echo $tt->getEndHiddenFieldValue('_documents_id'); if ($tt->isPredefinedField('_documents_id')) { if (isset($values['_documents_id']) && is_array($values['_documents_id']) && count($values['_documents_id'])) { echo "<span class='b'>" . __('Default documents:') . '</span>'; echo "<br>"; $doc = new Document(); foreach ($values['_documents_id'] as $key => $val) { if ($doc->getFromDB($val)) { echo "<input type='hidden' name='_documents_id[{$key}]' value='{$val}'>"; echo "- " . $doc->getNameID() . "<br>"; } } } } echo "<div id='fileupload_info'></div>"; echo "</td>"; echo "</tr>"; if ((!$ID || $canupdate || $canupdate_descr || Session::haveRightsOr(self::$rightname, array(self::ASSIGN, self::STEAL, DELETE, PURGE))) && !$options['template_preview']) { echo "<tr class='tab_bg_1'>"; if ($ID) { if (Session::haveRightsOr(self::$rightname, array(UPDATE, DELETE, PURGE)) || $this->canDeleteItem() || $this->canUpdateItem()) { echo "<td class='tab_bg_2 center' colspan='4'>"; if ($this->fields["is_deleted"] == 1) { if (self::canPurge()) { echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'> "; } } else { if (self::canUpdate()) { echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'> "; } } if ($this->fields["is_deleted"] == 1) { if (self::canPurge()) { echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">"; } } else { if ($this->canDeleteItem()) { echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'>"; } } echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>"; echo "</td>"; } } else { echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; if ($tt->isField('id') && $tt->fields['id'] > 0) { echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>"; echo "<input type='hidden' name='_predefined_fields'\n value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">"; } } } // File upload system $colspan = 3; if (!$CFG_GLPI['use_rich_text']) { $colspan = 4; } echo "<tr class='tab_bg_1'>"; echo "<td colspan='{$colspan}'>"; echo $tt->getBeginHiddenFieldValue('_documents_id'); echo Html::file(array('multiple' => true, 'showfilecontainer' => 'fileupload_info', 'values' => array('filename' => $values['_filename'], 'tag' => $values['_tag_filename']))); echo "</td>"; if ($CFG_GLPI['use_rich_text']) { echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='{$colspan}'>"; if (!isset($rand)) { $rand = mt_rand(); } if ($canupdate_descr) { echo Html::initImagePasteSystem($content_id, $rand); } echo "</td>"; } echo "</tr>"; echo "</table>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "</div>"; if (!$options['template_preview']) { Html::closeForm(); } return true; }
/** * The original document's type, such as Sales Invoice or Purchase Invoice. * * @var string * @see DocumentType */ public function setDocType($value) { DocumentType::Validate($value); $this->DocType = $value; return $this; }
function form_changetype() { $oForm = new KTForm(); $oForm->setOptions(array('label' => _kt("Change Document Type"), 'description' => _kt("Changing the document type will allow different metadata to be associated with it."), 'identifier' => 'ktcore.doc.edit.typechange', 'submit_label' => _kt("Update Document"), 'context' => $this, 'cancel_action' => 'main', 'action' => 'trytype')); $type = DocumentType::get($this->oDocument->getDocumentTypeId()); $current_type_name = $type->getName(); $oFolder = Folder::get($this->oDocument->getFolderID()); $oForm->setWidgets(array(array('ktcore.widgets.entityselection', array('label' => _kt("New Document Type"), 'description' => _kt("Please select the new type for this document."), 'important_description' => sprintf(_kt("The document is currently of type \"%s\"."), $current_type_name), 'value' => $type->getId(), 'label_method' => 'getName', 'vocab' => DocumentType::getListForUserAndFolder($this->oUser, $oFolder), 'simple_select' => false, 'required' => true, 'name' => 'type')))); $oForm->setValidators(array(array('ktcore.validators.entity', array('test' => 'type', 'output' => 'type', 'class' => 'DocumentType')))); return $oForm; }
function do_viewComparison() { $document_data = array(); $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if ($document_id === null) { $this->oPage->addError(sprintf(_kt("No document was requested. Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl())); return $this->do_error(); } $document_data['document_id'] = $document_id; $base_version = KTUtil::arrayGet($_REQUEST, 'fBaseVersion'); // try get the document. $oDocument =& Document::get($document_id, $base_version); if (PEAR::isError($oDocument)) { $this->oPage->addError(sprintf(_kt("The base document you attempted to retrieve is invalid. Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl())); return $this->do_error(); } if (!Permission::userHasDocumentReadPermission($oDocument)) { // FIXME inconsistent. $this->oPage->addError(_kt('You are not allowed to view this document')); return $this->permissionDenied(); } $this->oDocument =& $oDocument; $this->oPage->setSecondaryTitle($oDocument->getName()); $aOptions = array('documentaction' => 'viewDocument', 'folderaction' => 'browse'); $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions)); $this->oPage->setBreadcrumbDetails(_kt('compare versions')); $comparison_version = KTUtil::arrayGet($_REQUEST, 'fComparisonVersion'); if ($comparison_version === null) { $this->oPage->addError(sprintf(_kt("No comparison version was requested. Please <a href=\"%s\">select a version</a>."), KTUtil::addQueryStringSelf('action=history&fDocumentId=' . $document_id))); return $this->do_error(); } $oComparison =& Document::get($oDocument->getId(), $comparison_version); if (PEAR::isError($oComparison)) { $this->errorRedirectToMain(_kt('Invalid document to compare against.')); } $comparison_data = array(); $comparison_data['document_id'] = $oComparison->getId(); $document_data['document'] = $oDocument; $comparison_data['document'] = $oComparison; $document_data['document_type'] =& DocumentType::get($oDocument->getDocumentTypeID()); $comparison_data['document_type'] =& DocumentType::get($oComparison->getDocumentTypeID()); // follow twice: once for normal, once for comparison. $is_valid_doctype = true; if (PEAR::isError($document_data['document_type'])) { $this->oPage->addError(_kt('The document you requested has an invalid <strong>document type</strong>. Unfortunately, this means that we cannot effectively display it.')); $is_valid_doctype = false; } // we want to grab all the md for this doc, since its faster that way. $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($base_version))); $field_values = array(); foreach ($mdlist as $oFieldLink) { $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue(); } $document_data['field_values'] = $field_values; $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($comparison_version))); $field_values = array(); foreach ($mdlist as $oFieldLink) { $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue(); } $comparison_data['field_values'] = $field_values; // Fieldset generation. // // we need to create a set of FieldsetDisplay objects // that adapt the Fieldsets associated with this lot // to the view (i.e. ZX3). Unfortunately, we don't have // any of the plumbing to do it, so we handle this here. $fieldsets = array(); // we always have a generic. array_push($fieldsets, new GenericFieldsetDisplay()); // FIXME can we key this on fieldset namespace? or can we have duplicates? // now we get the other fieldsets, IF there is a valid doctype. if ($is_valid_doctype) { // these are the _actual_ fieldsets. $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton(); // and the generics $activesets = KTFieldset::getGenericFieldsets(); foreach ($activesets as $oFieldset) { $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace()); array_push($fieldsets, new $displayClass($oFieldset)); } $activesets = KTFieldset::getForDocumentType($oDocument->getDocumentTypeID()); foreach ($activesets as $oFieldset) { $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace()); array_push($fieldsets, new $displayClass($oFieldset)); } } // FIXME handle ad-hoc fieldsets. $this->addPortlets(); $oTemplate = $this->oValidator->validateTemplate('ktcore/document/compare'); $aTemplateData = array('context' => $this, 'document_id' => $document_id, 'document' => $oDocument, 'document_data' => $document_data, 'comparison_data' => $comparison_data, 'comparison_document' => $oComparison, 'fieldsets' => $fieldsets); //var_dump($aTemplateData['comparison_data']); return $oTemplate->render($aTemplateData); }
function __construct( $file, $path ) { parent::__construct( $file, $path ); }
/** * Find a valid path for the new file * * @param $dir dir to search a free path for the file * @param $sha1sum SHA1 of the file * * @return nothing **/ static function getUploadFileValidLocationName($dir, $sha1sum) { global $CFG_GLPI, $LANG; if (empty($dir)) { $message = $LANG['document'][32]; if (haveRight('dropdown', 'r')) { $dt = new DocumentType(); $message .= " <a target='_blank' href='" . $dt->getSearchURL() . "'>\n <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/aide.png\"></a>"; } addMessageAfterRedirect($message, false, ERROR); return ''; } if (!is_dir(GLPI_DOC_DIR)) { addMessageAfterRedirect($LANG['document'][31] . " " . GLPI_DOC_DIR, false, ERROR); return ''; } $subdir = $dir . '/' . substr($sha1sum, 0, 2); if (!is_dir(GLPI_DOC_DIR . "/" . $subdir) && @mkdir(GLPI_DOC_DIR . "/" . $subdir, 0777, true)) { addMessageAfterRedirect($LANG['document'][34] . " " . GLPI_DOC_DIR . "/" . $subdir); } if (!is_dir(GLPI_DOC_DIR . "/" . $subdir)) { addMessageAfterRedirect($LANG['document'][29] . " " . GLPI_DOC_DIR . "/" . $subdir . " " . $LANG['document'][30], false, ERROR); return ''; } return $subdir . '/' . substr($sha1sum, 2) . '.' . $dir; }
/** * Create a table of the document metadata. * Hard coded for the moment * * @return unknown */ function getMetadata() { /* Get document info */ // Filename $sFilenameLb = _kt('Document Filename: '); $sFilename = $this->_oDocument->getFileName(); // Mime type $sMimeTypeLb = _kt('File is a: '); $iMimeId = $this->_oDocument->getMimeTypeID(); $sMimeType = KTMime::getMimeTypeName($iMimeId); $sMimeType = KTMime::getFriendlyNameForString($sMimeType); // Version $sVersionLb = _kt('Document Version: '); $iVersion = $this->_oDocument->getVersion(); // Created by $sCreatedByLb = _kt('Created by: '); $iCreatorId = $this->_oDocument->getCreatorID(); $sCreated = $this->_oDocument->getCreatedDateTime(); $oCreator = User::get($iCreatorId); $sCreatedBy = $oCreator->getName() . ' (' . $sCreated . ')'; // Owned by $sOwnedByLb = _kt('Owned by: '); $iOwnedId = $this->_oDocument->getOwnerID(); $oOwner = User::get($iOwnedId); $sOwnedBy = $oOwner->getName(); // Last update by $iModifiedId = $this->_oDocument->getModifiedUserId(); $sLastUpdatedByLb = ''; $sLastUpdatedBy = ''; if (!empty($iModifiedId)) { $sLastUpdatedByLb = _kt('Last updated by: '); $sModified = $this->_oDocument->getLastModifiedDate(); $oModifier = User::get($iModifiedId); $sLastUpdatedBy = $oModifier->getName() . ' (' . $sModified . ')'; } // Document type $sDocTypeLb = _kt('Document Type: '); $iDocTypeId = $this->_oDocument->getDocumentTypeID(); $oDocType = DocumentType::get($iDocTypeId); $sDocType = $oDocType->getName(); // Workflow $iWFId = $this->_oDocument->getWorkflowId(); $sWF = ''; $sWFLb = ''; if (!empty($iWFId)) { $sWFLb = _kt('Workflow: '); $iWFStateId = $this->_oDocument->getWorkflowStateId(); $oWF = KTWorkflow::get($iWFId); $sWF = $oWF->getHumanName(); $oWFState = KTWorkflowState::get($iWFStateId); $sWF .= ' (' . $oWFState->getHumanName() . ')'; } // Checked out by $sCheckedLb = ''; $sCheckedOutBy = ''; if ($this->_oDocument->getIsCheckedOut()) { $sCheckedLb = _kt('Checked out by: '); $iCheckedID = $this->_oDocument->getCheckedOutUserID(); $oCheckedUser = User::get($iCheckedID); $sCheckedOutBy = $oCheckedUser->getName(); } // Id $sIdLb = _kt('Document ID: '); $sId = $this->_IDocId; /* Create table */ $sInfo = "<div style='float:left; width:405px;'>\n <table cellspacing='3px' cellpadding='3px' width='405px'>\n <tr><td>{$sFilenameLb}</td><td><b>{$sFilename}</b></td></tr>\n <tr><td>{$sMimeTypeLb}</td><td><b>{$sMimeType}</b></td></tr>\n <tr><td>{$sVersionLb}</td><td><b>{$iVersion}</b></td></tr>\n <tr><td>{$sCreatedByLb}</td><td><b>{$sCreatedBy}</b></td></tr>\n <tr><td>{$sOwnedByLb}</td><td><b>{$sOwnedBy}</b></td></tr>"; if (!empty($sLastUpdatedBy)) { $sInfo .= "<tr><td>{$sLastUpdatedByLb}</td><td><b>{$sLastUpdatedBy}</b></td></tr>"; } $sInfo .= "<tr><td>{$sDocTypeLb}</td><td><b>{$sDocType}</b></td></tr>"; if (!empty($sWF)) { $sInfo .= "<tr><td>{$sWFLb}</td><td><b>{$sWF}</b></td></tr>"; } if (!empty($sCheckedOutBy)) { $sInfo .= "<tr><td>{$sCheckedLb}</td><td><b>{$sCheckedOutBy}</b></td></tr>"; } $sInfo .= "<tr><td>{$sIdLb}</td><td><b>{$sId}</b></td></tr>"; $sInfo .= " </table></div>"; return $sInfo; }
function do_finalise() { $this->persistParams(array('fFileKey')); $sess_key = $_REQUEST['fFileKey']; $oForm = $this->form_metadata($sess_key); $res = $oForm->validate(); if (!empty($res['errors'])) { return $oForm->handleError(); } $data = $res['results']; $extra_d = $_SESSION['_add_data'][$sess_key]; $doctypeid = $extra_d['document_type']; $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false)); $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false)); $fieldsets = kt_array_merge($aGenericFieldsetIds, $aSpecificFieldsetIds); $MDPack = array(); foreach ($fieldsets as $oFieldset) { $fields = $oFieldset->getFields(); $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId()); foreach ($fields as $oField) { $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); if ($oFieldset->getIsConditional()) { if ($val == _kt('No selection.')) { $val = null; } } // ALT.METADATA.LAYER.DIE.DIE.DIE if (!is_null($val)) { $MDPack[] = array($oField, $val); } } } // older code $mpo =& new JavascriptObserver($this); $oUploadChannel =& KTUploadChannel::getSingleton(); $oUploadChannel->addObserver($mpo); require_once KT_LIB_DIR . '/storage/storagemanager.inc.php'; //require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); require_once KT_LIB_DIR . '/documentmanagement/DocumentType.inc'; require_once KT_LIB_DIR . '/metadata/fieldset.inc.php'; require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'; $aErrorOptions = array('redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())), 'max_str_len' => 200); $aFile = $this->oValidator->validateFile($extra_d['file'], $aErrorOptions); $sTitle = $extra_d['document_name']; $iFolderId = $this->oFolder->getId(); $aOptions = array('temp_file' => $aFile['tmp_name'], 'documenttype' => DocumentType::get($extra_d['document_type']), 'metadata' => $MDPack, 'description' => $sTitle, 'cleanup_initial_file' => true); $mpo->start(); //$this->startTransaction(); $oDocument =& KTDocumentUtil::add($this->oFolder, $aFile['name'], $this->oUser, $aOptions); if (PEAR::isError($oDocument)) { $message = $oDocument->getMessage(); $this->errorRedirectTo('main', sprintf(_kt("Unexpected failure to add document - %s"), $message), 'fFolderId=' . $this->oFolder->getId()); exit(0); } $this->addInfoMessage(_kt("Document added")); //$this->commitTransaction(); $mpo->redirectToDocument($oDocument->getId()); exit(0); }
/** * Exclude object from result * * @param DocumentType $documentType Object to remove from the list of results * * @return DocumentTypeQuery The current query, for fluid interface */ public function prune($documentType = null) { if ($documentType) { $this->addUsingAlias(DocumentTypePeer::ID, $documentType->getId(), Criteria::NOT_EQUAL); } return $this; }
function __construct($id, $clientid, $name, $type, $serial, $parcel, $details, $status, $lastUpdated, $timestamp, $file, $thumbnail) { $this->id = $id; $this->client = Client::GetClient($clientid); $this->name = $name; $this->type = DocumentType::Get($type); $this->serial = $serial; $this->parcel = $parcel; $this->details = $details; $this->status = $status; $this->lastUpdated = $lastUpdated; $this->timestamp = $timestamp; $this->file = $file; $this->thumbnail = $thumbnail; }
function renderData($aDataRow) { // only show this for documents. if ($aDataRow['type'] === 'folder') { return ' '; } // Check if document is checked out $iDocTypeId = $aDataRow['document']->getDocumentTypeID(); if (!empty($iDocTypeId)) { $oDocumentType = DocumentType::get($iDocTypeId); $sType = $oDocumentType->getName(); return '<span class="descriptive">' . htmlentities($sType, ENT_NOQUOTES, 'UTF-8') . '</span>'; } return '—'; }
/** * This returns detailed information on the document. * * @author KnowledgeTree Team * @access public * @return array The document information */ function get_detail() { global $default; // make sure we ge tthe latest $this->clearCache(); $config = KTConfig::getSingleton(); $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION); $detail = array(); $document = $this->document; // get the document id $detail['document_id'] = (int) $document->getId(); $oem_document_no = null; if ($wsversion >= 2) { $oem_document_no = $document->getOemNo(); } if (empty($oem_document_no)) { $oem_document_no = 'n/a'; } $detail['custom_document_no'] = 'n/a'; $detail['oem_document_no'] = $oem_document_no; // get the title $detail['title'] = $document->getName(); // get the document type $documenttypeid = $document->getDocumentTypeID(); $documenttype = '* unknown *'; if (is_numeric($documenttypeid)) { $dt = DocumentType::get($documenttypeid); if (!is_null($dt) && !PEAR::isError($dt)) { $documenttype = $dt->getName(); } } $detail['document_type'] = $documenttype; // get the filename $detail['filename'] = $document->getFilename(); // get the filesize $detail['filesize'] = (int) $document->getFileSize(); // get the folder id $detail['folder_id'] = (int) $document->getFolderID(); // get the creator $userid = $document->getCreatorID(); $username = '******'; if (is_numeric($userid)) { $username = '******'; $user = User::get($userid); if (!is_null($user) && !PEAR::isError($user)) { $username = $user->getName(); } } $detail['created_by'] = $username; // get the creation date $detail['created_date'] = $document->getCreatedDateTime(); // get the checked out user $userid = $document->getCheckedOutUserID(); $username = '******'; if (is_numeric($userid)) { $username = '******'; $user = User::get($userid); if (!is_null($user) && !PEAR::isError($user)) { $username = $user->getName(); } } $detail['checked_out_by'] = $username; // get the checked out date list($major, $minor, $fix) = explode('.', $default->systemVersion); if ($major == 3 && $minor >= 5) { $detail['checked_out_date'] = $document->getCheckedOutDate(); } else { $detail['checked_out_date'] = $detail['modified_date']; } if (is_null($detail['checked_out_date'])) { $detail['checked_out_date'] = 'n/a'; } // get the modified user $userid = $document->getModifiedUserId(); $username = '******'; if (is_numeric($userid)) { $username = '******'; $user = User::get($userid); if (!is_null($user) && !PEAR::isError($user)) { $username = $user->getName(); } } $detail['modified_by'] = $detail['updated_by'] = $username; // get the modified date $detail['updated_date'] = $detail['modified_date'] = $document->getLastModifiedDate(); // get the owner $userid = $document->getOwnerID(); $username = '******'; if (is_numeric($userid)) { $username = '******'; $user = User::get($userid); if (!is_null($user) && !PEAR::isError($user)) { $username = $user->getName(); } } $detail['owned_by'] = $username; // get the version $detail['version'] = $document->getVersion(); if ($wsversion >= 2) { $detail['version'] = (double) $detail['version']; } //might be unset at the bottom in case of old webservice version //make sure we're using the real document for this one $this->document->switchToRealCore(); $detail['linked_document_id'] = $document->getLinkedDocumentId(); $this->document->switchToLinkedCore(); // check immutability $detail['is_immutable'] = (bool) $document->getImmutable(); // check permissions $detail['permissions'] = KTAPI_Document::get_permission_string($document); // get workflow name $workflowid = $document->getWorkflowId(); $workflowname = 'n/a'; if (is_numeric($workflowid)) { $workflow = KTWorkflow::get($workflowid); if (!is_null($workflow) && !PEAR::isError($workflow)) { $workflowname = $workflow->getName(); } } $detail['workflow'] = $workflowname; // get the workflow state $stateid = $document->getWorkflowStateId(); $workflowstate = 'n/a'; if (is_numeric($stateid)) { $state = KTWorkflowState::get($stateid); if (!is_null($state) && !PEAR::isError($state)) { $workflowstate = $state->getName(); } } $detail['workflow_state'] = $workflowstate; // get the full path $detail['full_path'] = '/' . $this->document->getFullPath(); // get mime info $mimetypeid = $document->getMimeTypeID(); $detail['mime_type'] = KTMime::getMimeTypeName($mimetypeid); $detail['mime_icon_path'] = KTMime::getIconPath($mimetypeid); $detail['mime_display'] = KTMime::getFriendlyNameForString($detail['mime_type']); // get the storage path $detail['storage_path'] = $document->getStoragePath(); if ($wsversion >= 2) { unset($detail['updated_by']); unset($detail['updated_date']); } if ($wsversion < 3) { unset($detail['linked_document_id']); } return $detail; }
/** * Find a valid path for the new file * * @param $dir dir to search a free path for the file * @param $sha1sum SHA1 of the file * * @return nothing **/ static function getUploadFileValidLocationName($dir, $sha1sum) { global $CFG_GLPI; if (empty($dir)) { $message = __('Unauthorized file type'); if (Session::haveRight('dropdown', READ)) { $dt = new DocumentType(); $message .= " <a target='_blank' href='" . $dt->getSearchURL() . "'>\n <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/aide.png\"></a>"; } Session::addMessageAfterRedirect($message, false, ERROR); return ''; } if (!is_dir(GLPI_DOC_DIR)) { Session::addMessageAfterRedirect(sprintf(__("The directory %s doesn't exist."), GLPI_DOC_DIR), false, ERROR); return ''; } $subdir = $dir . '/' . substr($sha1sum, 0, 2); if (!is_dir(GLPI_DOC_DIR . "/" . $subdir) && @mkdir(GLPI_DOC_DIR . "/" . $subdir, 0777, true)) { Session::addMessageAfterRedirect(sprintf(__('Create the directory %s'), GLPI_DOC_DIR . "/" . $subdir)); } if (!is_dir(GLPI_DOC_DIR . "/" . $subdir)) { Session::addMessageAfterRedirect(sprintf(__('Failed to create the directory %s. Verify that you have the correct permission'), GLPI_DOC_DIR . "/" . $subdir), false, ERROR); return ''; } return $subdir . '/' . substr($sha1sum, 2) . '.' . $dir; }
function delDocumentType($id) { $tobeDeleted = new DocumentType($id); if ($tobeDeleted->isNew()) { return true; } // item never existed in the first place if ($tobeDeleted->del()) { return true; } else { return $tobeDeleted; } }
//new doc type being added directly on document form - returns updated drop down list case 'addDocumentType': if (isset($_POST['shortName']) && $_POST['shortName'] != '') { $documentType = new DocumentType(); $documentType->documentTypeID = ''; $documentType->shortName = $_POST['shortName']; try { $documentType->save(); } catch (Exception $e) { echo $e->getMessage(); } } echo "<select name='documentTypeID' id='documentTypeID'>"; $displayArray = array(); $display = array(); $documentType = new DocumentType(); $displayArray = $documentType->allAsArray(); foreach ($displayArray as $display) { if ($_POST['shortName'] == $display['shortName']) { echo "<option value='" . $display['documentTypeID'] . "' selected>" . $display['shortName'] . "</option>"; } else { echo "<option value='" . $display['documentTypeID'] . "'>" . $display['shortName'] . "</option>"; } } echo "</select>"; break; //new signature type being added directly on signature form - returns updated drop down list //no longer used.... must add signature types from admin form //new signature type being added directly on signature form - returns updated drop down list //no longer used.... must add signature types from admin form case 'addSignatureType':
public function acceptsURL($sUrl, $bCreateType = false) { $sFileName = substr($sUrl, strrpos($sUrl, '/') + 1); $aName = explode('.', $sFileName); $sExtension = null; if (count($aName) > 1) { $sExtension = array_pop($aName); } $sFileName = implode('.', $aName); $aHeaders = @get_headers($sUrl, true); $sMimeType = null; $oDocumentType = null; if ($aHeaders && isset($aHeaders['Content-Type'])) { $sMimeType = $aHeaders['Content-Type']; $oDocumentType = DocumentTypeQuery::findDocumentTypeByMimetype($sMimeType); } if ($oDocumentType === null && $sExtension !== null) { $oDocumentType = DocumentTypePeer::getDocumentTypeByExtension($sExtension); } if ($oDocumentType === null && $bCreateType && $sMimeType && $sExtension) { $oDocumentType = new DocumentType(); $oDocumentType->setExtension($sExtension); $oDocumentType->setMimetype($sMimeType); $oDocumentType->save(); } if ($oDocumentType === null) { throw new LocalizedException("wns.file_upload.document_type_not_found", array('extension' => $sExtension, 'mimetype' => $sMimeType)); } return $oDocumentType->getId(); }
function do_addfieldsets() { $oDocumentType =& DocumentType::get($_REQUEST['fDocumentTypeId']); $aFieldsetId = $_REQUEST['fieldsetid']; if (!count($aFieldsetId)) { $this->errorRedirectTo('edit', _kt('You must select at least one fieldset'), 'fDocumentTypeId=' . $oDocumentType->getId()); exit(0); } $res = KTMetadataUtil::addSetsToDocumentType($oDocumentType, $aFieldsetId); if (PEAR::isError($res)) { var_dump($res); $this->errorRedirectTo('edit', _kt('Changes not saved'), 'fDocumentTypeId=' . $oDocumentType->getId()); exit(0); } $this->successRedirectTo('edit', _kt('Fieldsets associated.'), 'fDocumentTypeId=' . $oDocumentType->getId()); exit(0); }
/** * Filter the query by a related DocumentType object * * @param DocumentType|PropelObjectCollection $documentType The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return DocumentQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByDocumentType($documentType, $comparison = null) { if ($documentType instanceof DocumentType) { return $this->addUsingAlias(DocumentPeer::DOCUMENT_TYPE_ID, $documentType->getId(), $comparison); } elseif ($documentType instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(DocumentPeer::DOCUMENT_TYPE_ID, $documentType->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByDocumentType() only accepts arguments of type DocumentType or PropelCollection'); } }
function do_selectType() { $aTypes = DocumentType::getList(); // FIXME what is the error message? $_REQUEST['fBrowseMode'] = 'document_type'; if (empty($aTypes)) { $this->errorRedirectToMain('No document types available.'); exit(0); } $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('kt3/browse_types'); $aTemplateData = array('context' => $this, 'document_types' => $aTypes); return $oTemplate->render($aTemplateData); }
/** * Manages all models. */ public function actionAdmin() { if ($this->menu_use[4]) { $doc_type_list = array(); $criteria = new CDbCriteria(); $criteria->condition = 'status=:status AND doc_group=\'download\''; $criteria->params = array(':status' => 1); $criteria->order = 'name_th'; $doc_type = DocumentType::model()->findAll($criteria); foreach ($doc_type as $type) { $doc_type_list[$type->doc_type_id] = $type->name_th; } $model = new Document('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['Document'])) { $model->attributes = $_GET['Document']; } $this->render('admin', array('model' => $model, 'doc_type_list' => $doc_type_list)); } else { $this->redirect(array('site/index')); } }
<?php /* @var $this DocumentController */ /* @var $model Document */ $this->breadcrumbs = array('สื่อเผยแพร่/ดาวน์โหลด' => array('index'), 'จัดการข้อมูล'); $this->menu = array(array('label' => 'เพิ่มข้อมูล', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$('#document-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>จัดการสื่อเผยแพร่/ดาวน์โหลด</h1> <?php echo CHtml::link('ค้นหาแบบละเอียด', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model, 'doc_type_list' => $doc_type_list)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'document-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('header' => 'ลำดับ', 'type' => 'raw', 'value' => '$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1', 'htmlOptions' => array('style' => 'text-align: center;width: 30px;')), array('name' => 'name_th', 'header' => 'สื่อเผยแพร่/ดาวน์โหลด'), array('name' => 'doc_type_id', 'header' => 'ประเภท', 'value' => '$data->documentType->name_th', 'htmlOptions' => array('style' => 'text-align: left;width: 150px;'), 'filter' => CHtml::listData(DocumentType::model()->findAll('status=1'), 'doc_type_id', 'name_th')), array('name' => 'last_update', 'header' => 'วันที่ปรับปรุง', 'value' => 'Controller::getThaiDate($data->last_update,"dmY")', 'htmlOptions' => array('style' => 'text-align: center;width: 80px;')), array('name' => 'status', 'value' => '($data->status)? \'แสดง\' : \'ไม่แสดง\'', 'htmlOptions' => array('style' => 'text-align: center;width: 50px;'), 'filter' => array('1' => 'แสดง', '0' => 'ไม่แสดง')), array('class' => 'CButtonColumn', 'template' => '{update} {delete}', 'headerHtmlOptions' => array('style' => 'width:40px;'), 'htmlOptions' => array('style' => 'width:40px; text-align:center')))));
public function deleteDocumentType($id) { if ($this->validateAdmin()) { if (DocumentType::Delete($id)) { echo 1; } else { echo 0; } } else { echo 0; } }
function &getAssociatedTypes() { // NOTE: this returns null if we are generic (all is the wrong answer) if ($this->getIsGeneric()) { return array(); } $sTable = KTUtil::getTableName('document_type_fieldsets'); $aQuery = array("SELECT document_type_id FROM {$sTable} WHERE fieldset_id = ?", array($this->getId())); $aIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id'); $aRet = array(); foreach ($aIds as $iID) { $oType = DocumentType::get($iID); if (!PEAR::isError($oType)) { $aRet[] = $oType; } } return $aRet; }
/** * This adds a document to the current folder. * * <code> * $kt = new KTAPI(); * $kt->start_session("admin", "admin"); * $folder = $kt->get_folder_by_name("My New folder"); * $res = $folder->add_document("Test Document", "test.txt", "Default", $tmpfname); * </code> * * @author KnowledgeTree Team * @access public * @param string $title This is the title for the file in the repository. * @param string $filename This is the filename in the system for the file. * @param string $documenttype This is the name or id of the document type. It first looks by name, then by id. * @param string $tempfilename This is a reference to the file that is accessible locally on the file system. * @return KTAPI_Document */ function add_document($title, $filename, $documenttype, $tempfilename) { if (!is_file($tempfilename)) { return new PEAR_Error('File does not exist.'); } $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_WRITE); if (PEAR::isError($user)) { return $user; } //KTS-4016: removed the replacing of special characters from the title as they should be allowed there //$title = KTUtil::replaceInvalidCharacters($title); $filename = basename($filename); $filename = KTUtil::replaceInvalidCharacters($filename); $documenttypeid = KTAPI::get_documenttypeid($documenttype); if (PEAR::isError($documenttypeid)) { $config = KTCache::getSingleton(); $defaultToDefaultDocType = $config->get('webservice/useDefaultDocumentTypeIfInvalid', true); if ($defaultToDefaultDocType) { $documenttypeid = KTAPI::get_documenttypeid('Default'); } else { return new KTAPI_DocumentTypeError('The document type could not be resolved or is disabled: ' . $documenttype); } } $options = array('contents' => new KTFSFileLike($tempfilename), 'temp_file' => $tempfilename, 'novalidate' => true, 'documenttype' => DocumentType::get($documenttypeid), 'description' => $title, 'metadata' => array(), 'cleanup_initial_file' => true); DBUtil::startTransaction(); $document =& KTDocumentUtil::add($this->folder, $filename, $user, $options); if (PEAR::isError($document)) { DBUtil::rollback(); return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR . ' : ' . $document->getMessage()); } DBUtil::commit(); KTUploadManager::temporary_file_imported($tempfilename); return new KTAPI_Document($this->ktapi, $this, $document); }