Document_Item::showSimpleAddForItem PHP Méthode

showSimpleAddForItem() static public méthode

static public showSimpleAddForItem ( CommonDBTM $item, $withtemplate = '', $colspan = 1 )
$item CommonDBTM
$withtemplate (default '')
$colspan
    static function showSimpleAddForItem(CommonDBTM $item, $withtemplate = '', $colspan = 1)
    {
        $entity = $_SESSION["glpiactive_entity"];
        if ($item->isEntityAssign()) {
            /// Case of personal items : entity = -1 : create on active entity (Reminder case))
            if ($item->getEntityID() >= 0) {
                $entity = $item->getEntityID();
            }
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Add a document') . "</td>";
        echo "<td colspan='{$colspan}'>";
        echo "<input type='hidden' name='entities_id' value='{$entity}'>";
        echo "<input type='hidden' name='is_recursive' value='" . $item->isRecursive() . "'>";
        echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
        echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>";
        if ($item->getType() == 'Ticket') {
            echo "<input type='hidden' name='tickets_id' value='" . $item->getID() . "'>";
        }
        echo Html::file(array('multiple' => true));
        echo "</td><td class='left'>(" . Document::getMaxUploadSize() . ")&nbsp;</td>";
        echo "<td></td></tr>";
    }

Usage Example

 /** form for Task
  *
  * @param $ID        Integer : Id of the task
  * @param $options   array
  *     -  parent Object : the object
  **/
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     if (isset($options['parent']) && !empty($options['parent'])) {
         $item = $options['parent'];
     }
     $fkfield = $item->getForeignKeyField();
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $options[$fkfield] = $item->getField('id');
         $this->check(-1, CREATE, $options);
     }
     $rand = mt_rand();
     $this->showFormHeader($options);
     $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED);
     $rowspan = 3;
     if ($this->maybePrivate()) {
         $rowspan++;
     }
     if (isset($this->fields["state"])) {
         $rowspan++;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td rowspan='{$rowspan}' class='middle'>" . __('Description') . "</td>";
     echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea id ='content{$rand}' name='content' cols='50' rows='{$rowspan}'>" . $this->fields["content"] . "</textarea>";
     echo Html::scriptBlock("\$(document).ready(function() { \$('#content{$rand}').autogrow(); });");
     echo "</td>";
     if ($ID > 0) {
         echo "<td>" . __('Date') . "</td>";
         echo "<td>";
         Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false));
     } else {
         echo "<td colspan='2'>&nbsp;";
     }
     echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Category') . "</td><td>";
     TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'entity' => $item->fields["entities_id"]));
     echo "</td></tr>\n";
     if (isset($this->fields["state"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Status') . "</td><td>";
         Planning::dropdownState("state", $this->fields["state"]);
         echo "</td></tr>\n";
     }
     if ($this->maybePrivate()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Private') . "</td>";
         echo "<td>";
         Dropdown::showYesNo('is_private', $this->fields["is_private"]);
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Duration') . "</td><td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "</td></tr>\n";
     Document_Item::showSimpleAddForItem($item);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('By');
     echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n             title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n             class='calendrier'>";
     echo "</a>";
     Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability')));
     echo "</td>";
     echo "<td class='center'>";
     $rand_user = mt_rand();
     $params = array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"] ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"]);
     $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
     User::dropdown($params);
     echo "</td>\n";
     if ($canplan) {
         echo "<td>" . __('Planning') . "</td>";
     }
     echo "<td>";
     if (!empty($this->fields["begin"])) {
         if (Session::haveRight('planning', Planning::READMY)) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlan" . $ID . "() {\n";
             echo Html::jsHide('plan');
             $params = array('form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "}";
             echo "</script>\n";
             echo "<div id='plan' onClick='showPlan" . $ID . "()'>\n";
             echo "<span class='showplan'>";
         }
         if (isset($this->fields["state"])) {
             echo Planning::getState($this->fields["state"]) . "<br>";
         }
         printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
         echo "<br>" . getUserName($this->fields["users_id_tech"]);
         if (Session::haveRight('planning', Planning::READMY)) {
             echo "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         }
     } else {
         if ($canplan) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlanUpdate() {\n";
             echo Html::jsHide('plan');
             $params = array('form' => 'followups', 'entity' => $_SESSION["glpiactive_entity"], 'rand_user' => $rand_user, 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "};";
             echo "</script>";
             if ($canplan) {
                 echo "<div id='plan'  onClick='showPlanUpdate()'>\n";
                 echo "<span class='vsubmit'>" . __('Plan this task') . "</span>";
                 echo "</div>\n";
                 echo "<div id='viewplan'></div>\n";
             }
         } else {
             _e('None');
         }
     }
     echo "</td></tr>";
     if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) {
         echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>";
         PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID()));
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
All Usage Examples Of Document_Item::showSimpleAddForItem