本文整理汇总了PHP中Supplier::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Supplier::getFromDB方法的具体用法?PHP Supplier::getFromDB怎么用?PHP Supplier::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Supplier
的用法示例。
在下文中一共展示了Supplier::getFromDB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transferSingleSupplier
/**
* Transfer an enterprise
*
* @param $ID ID of the enterprise
**/
function transferSingleSupplier($ID)
{
global $DB;
// TODO clean system : needed ?
$ent = new Supplier();
if ($this->options['keep_supplier'] && $ent->getFromDB($ID)) {
if (isset($this->noneedtobe_transfer['Supplier'][$ID])) {
// recursive enterprise
return $ID;
} else {
if (isset($this->already_transfer['Supplier'][$ID])) {
// Already transfer
return $this->already_transfer['Supplier'][$ID];
} else {
$newID = -1;
// Not already transfer
$links_remaining = 0;
// All linked items need to be transfer so transfer enterprise ?
// Search for contract
$query = "SELECT count(*) AS CPT\n FROM `glpi_contracts_suppliers`\n WHERE `suppliers_id` = '{$ID}'\n AND `contracts_id` NOT IN " . $this->item_search['Contract'];
$result_search = $DB->query($query);
$links_remaining = $DB->result($result_search, 0, 'CPT');
if ($links_remaining == 0) {
// Search for infocoms
if ($this->options['keep_infocom']) {
foreach ($this->INFOCOMS_TYPES as $itemtype) {
$query = "SELECT count(*) AS CPT\n FROM `glpi_infocoms`\n WHERE `suppliers_id` = '{$ID}'\n AND `itemtype` = '{$itemtype}'\n AND `items_id` NOT IN " . $this->item_search[$itemtype];
if ($result_search = $DB->query($query)) {
$links_remaining += $DB->result($result_search, 0, 'CPT');
}
}
}
}
// All linked items need to be transfer -> use unique transfer system
if ($links_remaining == 0) {
$this->transferItem('Supplier', $ID, $ID);
$newID = $ID;
} else {
// else Transfer by Copy
// Is existing item in the destination entity ?
$query = "SELECT *\n FROM `glpi_suppliers`\n WHERE `entities_id` = '" . $this->to . "'\n AND `name` = '" . addslashes($ent->fields['name']) . "'";
if ($result_search = $DB->query($query)) {
if ($DB->numrows($result_search) > 0) {
$newID = $DB->result($result_search, 0, 'id');
$this->addToAlreadyTransfer('Supplier', $ID, $newID);
}
}
// Not found -> transfer copy
if ($newID < 0) {
// 1 - create new item
unset($ent->fields['id']);
$input = $ent->fields;
$input['entities_id'] = $this->to;
unset($ent->fields);
$newID = $ent->add($input);
// 2 - transfer as copy
$this->transferItem('Supplier', $ID, $newID);
}
// Founded -> use to link : nothing to do
}
return $newID;
}
}
}
return 0;
}
示例2: showSupplierNotificationForm
/**
* Print the object user form for notification
*
* @since version 0.85
*
* @param $ID integer ID of the item
* @param $options array
*
* @return Nothing (display)
**/
function showSupplierNotificationForm($ID, $options = array())
{
global $CFG_GLPI;
$this->check($ID, UPDATE);
if (!isset($this->fields['suppliers_id'])) {
return false;
}
$item = new static::$itemtype_1();
echo "<br><form method='post' action='" . $_SERVER['PHP_SELF'] . "'>";
echo "<div class='center'>";
echo "<table class='tab_cadre' width='80%'>";
echo "<tr class='tab_bg_2'><td>" . $item->getTypeName(1) . "</td>";
echo "<td>";
if ($item->getFromDB($this->fields[static::getItilObjectForeignKey()])) {
echo $item->getField('name');
}
echo "</td></tr>";
$supplier = new Supplier();
$default_email = "";
if ($supplier->getFromDB($this->fields["suppliers_id"])) {
$default_email = $supplier->fields['email'];
}
echo "<tr class='tab_bg_2'><td>" . __('User') . "</td>";
echo "<td>" . $supplier->getName() . "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . __('Email Followup') . "</td>";
echo "<td>";
Dropdown::showYesNo('use_notification', $this->fields['use_notification']);
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . __('Email') . "</td>";
echo "<td>";
if (empty($this->fields['alternative_email'])) {
$this->fields['alternative_email'] = $default_email;
}
echo "<input type='text' size='40' name='alternative_email' value='" . $this->fields['alternative_email'] . "'>";
echo "</td></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td class='center' colspan='2'>";
echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
echo "<input type='hidden' name='id' value='{$ID}'>";
echo "</td></tr>";
echo "</table></div>";
Html::closeForm();
}
示例3: showSuppliersAssociated
/**
* show suppliers associated
*
* @since version 0.84
*
* @param $type integer : user type
* @param $canedit boolean : can edit ?
* @param $options array options for default values ($options of showForm)
*
* @return nothing display
**/
function showSuppliersAssociated($type, $canedit, array $options = array())
{
global $CFG_GLPI;
$showsupplierlink = 0;
if (Session::haveRight('contact_enterprise', READ)) {
$showsupplierlink = 2;
}
$suppliericon = self::getActorIcon('supplier', $type);
$supplier = new Supplier();
$linksupplier = new $this->supplierlinkclass();
$itemtype = $this->getType();
$typename = self::getActorFieldNameType($type);
$candelete = true;
$mandatory = '';
// For ticket templates : mandatories
if ($itemtype == 'Ticket' && isset($options['_tickettemplate'])) {
$mandatory = $options['_tickettemplate']->getMandatoryMark("_suppliers_id_" . $typename);
if ($options['_tickettemplate']->isMandatoryField("_suppliers_id_" . $typename) && isset($this->suppliers[$type]) && count($this->suppliers[$type]) == 1) {
$candelete = false;
}
}
if (isset($this->suppliers[$type]) && count($this->suppliers[$type])) {
foreach ($this->suppliers[$type] as $d) {
$k = $d['suppliers_id'];
echo "{$mandatory}{$suppliericon} ";
if ($supplier->getFromDB($k)) {
echo $supplier->getLink(array('comments' => $showsupplierlink));
echo " ";
$tmpname = Dropdown::getDropdownName($supplier->getTable(), $k, 1);
Html::showToolTip($tmpname['comment']);
if ($CFG_GLPI['use_mailing']) {
$text = __('Email followup') . " " . Dropdown::getYesNo($d['use_notification']) . '<br>';
if ($d['use_notification']) {
$supemail = $d['alternative_email'];
if (empty($supemail)) {
$supemail = $supplier->fields['email'];
}
$text .= sprintf(__('%1$s: %2$s'), __('Email'), $supemail);
}
echo " ";
if ($canedit) {
$opt = array('img' => $CFG_GLPI['root_doc'] . '/pics/edit.png', 'popup' => $linksupplier->getFormURL() . "?id=" . $d['id']);
Html::showToolTip($text, $opt);
}
}
}
if ($canedit && $candelete) {
echo " ";
Html::showSimpleForm($linksupplier->getFormURL(), 'delete', _x('button', 'Delete permanently'), array('id' => $d['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png");
}
echo '<br>';
}
}
}
示例4: generateOrder
public function generateOrder($params)
{
global $DB;
$ID = $params['id'];
$template = $params['template'];
$signature = $params['sign'];
if ($template) {
$config = array('PATH_TO_TMP' => GLPI_DOC_DIR . '/_tmp');
$odf = new Odtphp\Odf(PLUGIN_ORDER_TEMPLATE_DIR . "{$template}", $config);
$this->getFromDB($ID);
if (file_exists(PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR . "custom.php")) {
include_once PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR . "custom.php";
}
if (function_exists("plugin_order_getCustomFieldsForODT")) {
plugin_order_getCustomFieldsForODT($ID, $template, $odf, $signature);
} else {
$PluginOrderOrder_Item = new PluginOrderOrder_Item();
$PluginOrderReference_Supplier = new PluginOrderReference_Supplier();
try {
$odf->setImage('logo', PLUGIN_ORDER_TEMPLATE_LOGO_DIR . '/logo.jpg');
} catch (\Odtphp\Exceptions\OdfException $e) {
}
$values = array();
$values['title_order'] = __("Order number", "order");
$values['num_order'] = $this->fields["num_order"];
$values['title_invoice_address'] = __("Invoice address", "order");
$values['comment_order'] = $this->fields["comment"];
$entity = new Entity();
$entity->getFromDB($this->fields["entities_id"]);
$town = '';
if ($this->fields["entities_id"] != 0) {
$name_entity = $entity->fields["name"];
} else {
$name_entity = __("Root entity");
}
$values['entity_name'] = $name_entity;
if ($entity->getFromDB($this->fields["entities_id"])) {
$town = $entity->fields["town"];
$values['entity_address'] = $entity->fields["address"];
$values['entity_postcode'] = $entity->fields["postcode"];
$values['entity_town'] = $entity->fields["town"];
$values['entity_country'] = $entity->fields["country"];
}
$supplier = new Supplier();
if ($supplier->getFromDB($this->fields["suppliers_id"])) {
$values['supplier_name'] = $supplier->fields["name"];
$values['supplier_address'] = $supplier->fields["address"];
$values['supplier_postcode'] = $supplier->fields["postcode"];
$values['supplier_town'] = $supplier->fields["town"];
$values['supplier_country'] = $supplier->fields["country"];
}
$location = new Location();
if ($location->getFromDB($this->fields["locations_id"])) {
$values['title_delivery_address'] = __("Delivery address", "order");
$values['comment_delivery_address'] = $location->fields['comment'];
}
if ($town) {
$town = $town . ", ";
}
$order_date = Html::convDate($this->fields["order_date"]);
$username = Html::clean(getUserName(Session::getLoginUserID()));
$values['title_date_order'] = $town . __("The", "order") . " ";
$values['date_order'] = $order_date;
$values['title_sender'] = __("Issuer order", "order");
$values['sender'] = $username;
$values['title_budget'] = __("Budget");
$budget = new Budget();
if ($budget->getFromDB($this->fields["budgets_id"])) {
$values['budget'] = $budget->fields['name'];
} else {
$values['budget'] = '';
}
$output = '';
$contact = new Contact();
if ($contact->getFromDB($this->fields["contacts_id"])) {
$output = formatUserName($contact->fields["id"], "", $contact->fields["name"], $contact->fields["firstname"]);
}
$values['title_recipient'] = __("Recipient", "order");
$values['recipient'] = Html::clean($output);
$values['nb'] = __("Quantity", "order");
$values['title_item'] = __("Designation", "order");
$values['title_ref'] = __("Reference");
$values['HTPrice_item'] = __("Unit price", "order");
$values['TVA_item'] = __("VAT", "order");
$values['title_discount'] = __("Discount rate", "order");
$values['HTPriceTotal_item'] = __("Sum tax free", "order");
$values['ATIPriceTotal_item'] = __("Price ATI", "order");
$listeArticles = array();
$result = $PluginOrderOrder_Item->queryDetail($ID);
$num = $DB->numrows($result);
while ($data = $DB->fetch_array($result)) {
$quantity = $PluginOrderOrder_Item->getTotalQuantityByRefAndDiscount($ID, $data["id"], $data["price_taxfree"], $data["discount"]);
$listeArticles[] = array('quantity' => $quantity, 'ref' => utf8_decode($data["name"]), 'taxe' => Dropdown::getDropdownName(getTableForItemType("PluginOrderOrderTax"), $data["plugin_order_ordertaxes_id"]), 'refnumber' => $PluginOrderReference_Supplier->getReferenceCodeByReferenceAndSupplier($data["id"], $this->fields["suppliers_id"]), 'price_taxfree' => $data["price_taxfree"], 'discount' => $data["discount"], false, 0, 'price_discounted' => $data["price_discounted"] * $quantity, 'price_ati' => $data["price_ati"]);
}
$article = $odf->setSegment('articles');
foreach ($listeArticles as $element) {
$article->nbA($element['quantity']);
$article->titleArticle($element['ref']);
$article->refArticle($element['refnumber']);
$article->TVAArticle($element['taxe']);
//.........这里部分代码省略.........
示例5: showListForSupplier
static function showListForSupplier($entID)
{
global $DB, $CFG_GLPI, $LANG;
if (!haveRight("show_all_ticket", "1")) {
return false;
}
$query = "SELECT " . self::getCommonSelect() . "\n FROM `glpi_tickets` " . self::getCommonLeftJoin() . "\n WHERE (`suppliers_id_assign` = '{$entID}') " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n ORDER BY `glpi_tickets`.`date_mod` DESC\n LIMIT " . intval($_SESSION['glpilist_limit']);
$result = $DB->query($query);
$number = $DB->numrows($result);
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
if ($number > 0) {
$ent = new Supplier();
$ent->getFromDB($entID);
initNavigateListItems('Ticket', $LANG['financial'][26] . " = " . $ent->fields['name']);
$options['field'][0] = 6;
$options['searchtype'][0] = 'equals';
$options['contains'][0] = $entID;
$options['link'][0] = 'AND';
$options['reset'] = 'reset';
echo "<tr><th colspan='11'>";
if ($number == 1) {
echo $LANG['job'][10] . " : " . $number;
echo "<span class='small_space'><a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "'>" . $LANG['buttons'][40] . "</a></span>";
} else {
echo $LANG['job'][8] . " : " . $number;
echo "<span class='small_space'><a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "'>" . $LANG['buttons'][40] . "</a></span>";
}
echo "</th></tr>";
self::commonListHeader(HTML_OUTPUT);
while ($data = $DB->fetch_assoc($result)) {
addToNavigateListItems('Ticket', $data["id"]);
self::showShort($data["id"], 0);
}
} else {
echo "<tr><th>" . $LANG['joblist'][8] . "</th></tr>";
}
echo "</table></div>";
}
示例6: showSuppliersAssociated
/**
* show suppliers associated
*
* @since version 0.84
*
* @param $type integer : user type
* @param $canedit boolean : can edit ?
*
* @return nothing display
**/
function showSuppliersAssociated($type, $canedit, array $options = array())
{
global $CFG_GLPI;
$showsupplierlink = 0;
if (Session::haveRight('contact_enterprise', 'r')) {
$showsupplierlink = 1;
}
$suppliericon = self::getActorIcon('supplier', $type);
$supplier = new Supplier();
$itemtype = $this->getType();
$typename = self::getActorFieldNameType($type);
$candelete = true;
$mandatory = '';
// For ticket templates : mandatories
if ($itemtype == 'Ticket' && isset($options['_tickettemplate'])) {
$mandatory = $options['_tickettemplate']->getMandatoryMark("_suppliers_id_" . $typename);
if ($options['_tickettemplate']->isMandatoryField("_suppliers_id_" . $typename) && isset($this->suppliers[$type]) && count($this->suppliers[$type]) == 1) {
$candelete = false;
}
}
if (isset($this->suppliers[$type]) && count($this->suppliers[$type])) {
foreach ($this->suppliers[$type] as $d) {
$k = $d['suppliers_id'];
echo "{$mandatory}{$suppliericon} ";
if ($supplier->getFromDB($k)) {
echo $supplier->getLink(array('comments' => $showsupplierlink));
echo " ";
$tmpname = Dropdown::getDropdownName($supplier->getTable(), $k, 1);
Html::showToolTip($tmpname['comment']);
}
if ($canedit && $candelete) {
echo " ";
Html::showSimpleForm($this->getFormURL(), 'delete_supplier', _x('button', 'Delete permanently'), array('id' => $d['id'], $this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png");
}
echo '<br>';
}
}
}
示例7: header
$AJAX_INCLUDE = 1;
if (strpos($_SERVER['PHP_SELF'], "uemailUpdate.php")) {
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
Session::checkLoginUser();
if (isset($_POST['field']) && $_POST["value"] > 0 || isset($_POST['allow_email']) && $_POST['allow_email']) {
if (preg_match('/[^a-z_\\-0-9]/i', $_POST['field'])) {
throw new \RuntimeException('Invalid field provided!');
}
$default_email = "";
$emails = array();
if (isset($_POST['typefield']) && $_POST['typefield'] == 'supplier') {
$supplier = new Supplier();
if ($supplier->getFromDB($_POST["value"])) {
$default_email = $supplier->fields['email'];
}
} else {
$user = new User();
if ($user->getFromDB($_POST["value"])) {
$default_email = $user->getDefaultEmail();
$emails = $user->getAllEmails();
}
}
$user_index = 0;
if (isset($_POST['_user_index'])) {
$user_index = $_POST['_user_index'];
}
echo __('Email followup') . ' ';
$default_notif = true;
示例8: processMassiveActionsForOneItemtype
/**
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $CFG_GLPI;
$action = $ma->getAction();
switch ($action) {
case 'delete':
foreach ($ids as $id) {
if ($item->can($id, DELETE)) {
if ($item->delete(array("id" => $id))) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
break;
case 'restore':
foreach ($ids as $id) {
if ($item->can($id, PURGE)) {
if ($item->restore(array("id" => $id))) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
break;
case 'purge_item_but_devices':
case 'purge_but_item_linked':
case 'purge':
foreach ($ids as $id) {
if ($item->can($id, PURGE)) {
$force = 1;
// Only mark deletion for
if ($item->maybeDeleted() && $item->useDeletedToLockIfDynamic() && $item->isDynamic()) {
$force = 0;
}
$delete_array = array('id' => $id);
if ($action == 'purge_item_but_devices') {
$delete_array['keep_devices'] = true;
}
if ($item instanceof CommonDropdown) {
if ($item->haveChildren()) {
if ($action != 'purge_but_item_linked') {
$force = 0;
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage(__("You can't delete that item by massive actions, because it has sub-items"));
$ma->addMessage(__("but you can do it by the form of the item"));
continue;
}
}
if ($item->isUsed()) {
if ($action != 'purge_but_item_linked') {
$force = 0;
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage(__("You can't delete that item, because it is used for one or more items"));
$ma->addMessage(__("but you can do it by the form of the item"));
continue;
}
}
}
if ($item->delete($delete_array, $force)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
break;
case 'update':
if (!isset($ma->POST['search_options']) || !isset($ma->POST['search_options'][$item->getType()])) {
return false;
}
$index = $ma->POST['search_options'][$item->getType()];
$searchopt = Search::getCleanedOptions($item->getType(), UPDATE);
$input = $ma->POST;
if (isset($searchopt[$index])) {
/// Infocoms case
if (!isPluginItemType($item->getType()) && Search::isInfocomOption($item->getType(), $index)) {
$ic = new Infocom();
$link_entity_type = -1;
/// Specific entity item
if ($searchopt[$index]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($input[$input["field"]])) {
//.........这里部分代码省略.........
示例9: getTeamSuppliers
/**
* Add team suppliers to the notified user list
**/
function getTeamSuppliers()
{
global $DB, $CFG_GLPI;
$query = "SELECT `items_id`\n FROM `glpi_projecttaskteams`\n WHERE `glpi_projecttaskteams`.`itemtype` = 'Supplier'\n AND `glpi_projecttaskteams`.`projecttasks_id` = '" . $this->obj->fields["id"] . "'";
$supplier = new Supplier();
foreach ($DB->request($query) as $data) {
if ($supplier->getFromDB($data['items_id'])) {
$this->addToAddressesList(array("email" => $supplier->fields["email"], "name" => $supplier->getName(), "language" => $CFG_GLPI["language"], 'usertype' => NotificationTarget::ANONYMOUS_USER));
}
}
}
示例10: Infocom
if ($val == 1) {
$item->restore(array("id" => $key));
}
}
break;
case "update":
$searchopt = Search::getCleanedOptions($_POST["itemtype"], 'w');
if (isset($searchopt[$_POST["id_field"]])) {
/// Infocoms case
if (!isPluginItemType($_POST["itemtype"]) && Search::isInfocomOption($_POST["itemtype"], $_POST["id_field"])) {
$ic = new Infocom();
$link_entity_type = -1;
/// Specific entity item
if ($searchopt[$_POST["id_field"]]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($_POST[$_POST["field"]])) {
$link_entity_type = $ent->fields["entities_id"];
}
}
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
if ($item->getFromDB($key)) {
if ($link_entity_type < 0 || $link_entity_type == $item->getEntityID() || $ent->fields["is_recursive"] && in_array($link_entity_type, getAncestorsOf("glpi_entities", $item->getEntityID()))) {
// Add infocom if not exists
if (!$ic->getFromDBforDevice($_POST["itemtype"], $key)) {
$input2["items_id"] = $key;
$input2["itemtype"] = $_POST["itemtype"];
unset($ic->fields);
$ic->add($input2);
$ic->getFromDBforDevice($_POST["itemtype"], $key);
}
示例11: showSuppliersAssociated
/**
* show suppliers associated
*
* @since version 0.84
*
* @param $type integer : user type
* @param $canedit boolean : can edit ?
*
* @return nothing display
**/
function showSuppliersAssociated($type, $canedit)
{
global $CFG_GLPI;
$showsupplierlink = 0;
if (Session::haveRight('contact_enterprise', 'r')) {
$showsupplierlink = 1;
}
$suppliericon = self::getActorIcon('supplier', $type);
$supplier = new Supplier();
if (isset($this->suppliers[$type]) && count($this->suppliers[$type])) {
foreach ($this->suppliers[$type] as $d) {
$k = $d['suppliers_id'];
echo "{$suppliericon} ";
if ($supplier->getFromDB($k)) {
echo $supplier->getLink(array('comments' => $showsupplierlink));
}
if ($canedit) {
echo " ";
Html::showSimpleForm($this->getFormURL(), 'delete_supplier', _x('button', 'Delete permanently'), array('id' => $d['id'], $this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png");
}
echo '<br>';
}
}
}
示例12: showForm
public function showForm($ID, $options = array())
{
global $DB;
$plugin_order_references_id = -1;
if (isset($options['plugin_order_references_id'])) {
$plugin_order_references_id = $options['plugin_order_references_id'];
}
$this->initForm($ID, $options);
$this->showFormHeader($options);
$PluginOrderReference = new PluginOrderReference();
$PluginOrderReference->getFromDB($plugin_order_references_id);
echo "<input type='hidden' name='plugin_order_references_id' value='{$plugin_order_references_id}'>";
echo "<input type='hidden' name='entities_id' value='" . $PluginOrderReference->getEntityID() . "'>";
echo "<input type='hidden' name='is_recursive' value='" . $PluginOrderReference->isRecursive() . "'>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __("Supplier") . ": </td>";
echo "<td>";
if ($ID > 0) {
$supplier = new Supplier();
$supplier->getFromDB($this->fields['suppliers_id']);
echo $supplier->getLink(Session::haveRight('supplier', READ));
} else {
$suppliers = array();
$query = "SELECT `suppliers_id`\n FROM `" . $this->getTable() . "`\n WHERE `plugin_order_references_id` = '{$plugin_order_references_id}'";
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
$suppliers[] = $data["suppliers_id"];
}
Supplier::Dropdown(array('name' => 'suppliers_id', 'used' => $suppliers, 'entity' => $PluginOrderReference->getEntityID()));
}
echo "</td>";
echo "<td>" . __("Manufacturer's product reference", "order") . ": </td>";
echo "<td>";
Html::autocompletionTextField($this, "reference_code");
echo "</td></tr>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __("Unit price tax free", "order") . ": </td>";
echo "<td>";
echo "<input type='text' name='price_taxfree' value=\"" . Html::formatNumber($this->fields["price_taxfree"], true) . "\" size='7'>";
echo "</td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";
$options['candel'] = false;
$this->showFormButtons($options);
return true;
}
示例13: doMassiveActions
/**
* Do the standard massive actions
*
* @since version 0.84
*
* This must not be overloaded in Class
* @param $input array of input datas
*
* @return an array of results (ok, ko, noright counts, may include REDIRECT field to set REDIRECT page)
**/
function doMassiveActions($input = array())
{
global $CFG_GLPI;
if (!isset($input["item"]) || count($input["item"]) == 0) {
return false;
}
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
switch ($input['action']) {
case 'add_document':
case 'remove_document':
$doc = new Document();
return $doc->doSpecificMassiveActions($input);
case "add_transfer_list":
if (!isset($_SESSION['glpitransfer_list'])) {
$_SESSION['glpitransfer_list'] = array();
}
if (!isset($_SESSION['glpitransfer_list'][$input["itemtype"]])) {
$_SESSION['glpitransfer_list'][$input["itemtype"]] = array();
}
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
$_SESSION['glpitransfer_list'][$input["itemtype"]][$key] = $key;
$res['ok']++;
}
}
$res['REDIRECT'] = $CFG_GLPI['root_doc'] . '/front/transfer.action.php';
break;
case "delete":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
if ($this->delete(array("id" => $key))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "purge":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
$force = 1;
// Only mark deletion for
if ($this->maybeDeleted() && $this->useDeletedToLockIfDynamic() && $this->isDynamic()) {
$force = 0;
}
if ($this->delete(array("id" => $key), $force)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "restore":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
if ($this->restore(array("id" => $key))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "update":
$searchopt = Search::getCleanedOptions($input["itemtype"], 'w');
if (isset($searchopt[$input["id_field"]])) {
/// Infocoms case
if (!isPluginItemType($input["itemtype"]) && Search::isInfocomOption($input["itemtype"], $input["id_field"])) {
$ic = new Infocom();
$link_entity_type = -1;
/// Specific entity item
if ($searchopt[$input["id_field"]]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($input[$input["field"]])) {
$link_entity_type = $ent->fields["entities_id"];
}
//.........这里部分代码省略.........
示例14: getDatasForObject
/**
* @param $item CommonDBTM object
* @param $options array
* @param $simple (false by default)
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI, $DB;
$objettype = strtolower($item->getType());
$datas["##{$objettype}.title##"] = $item->getField('name');
$datas["##{$objettype}.content##"] = $item->getField('content');
$datas["##{$objettype}.description##"] = $item->getField('content');
$datas["##{$objettype}.id##"] = sprintf("%07d", $item->getField("id"));
if ($_SESSION['glpiticket_timeline'] == 1) {
$datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . '$1');
} else {
$datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id"));
}
$tab = '$2';
if ($_SESSION['glpiticket_timeline'] == 1) {
$tab = '$1';
}
$datas["##{$objettype}.urlapprove##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . $tab);
$entity = new Entity();
if ($entity->getFromDB($this->getEntity())) {
$datas["##{$objettype}.entity##"] = $entity->getField('completename');
$datas["##{$objettype}.shortentity##"] = $entity->getField('name');
}
$datas["##{$objettype}.storestatus##"] = $item->getField('status');
$datas["##{$objettype}.status##"] = $item->getStatus($item->getField('status'));
$datas["##{$objettype}.urgency##"] = $item->getUrgencyName($item->getField('urgency'));
$datas["##{$objettype}.impact##"] = $item->getImpactName($item->getField('impact'));
$datas["##{$objettype}.priority##"] = $item->getPriorityName($item->getField('priority'));
$datas["##{$objettype}.time##"] = $item->getActionTime($item->getField('actiontime'));
$datas["##{$objettype}.creationdate##"] = Html::convDateTime($item->getField('date'));
$datas["##{$objettype}.closedate##"] = Html::convDateTime($item->getField('closedate'));
$datas["##{$objettype}.solvedate##"] = Html::convDateTime($item->getField('solvedate'));
$datas["##{$objettype}.duedate##"] = Html::convDateTime($item->getField('due_date'));
$datas["##{$objettype}.category##"] = '';
if ($item->getField('itilcategories_id')) {
$datas["##{$objettype}.category##"] = Dropdown::getDropdownName('glpi_itilcategories', $item->getField('itilcategories_id'));
}
$datas["##{$objettype}.authors##"] = '';
$datas['authors'] = array();
if ($item->countUsers(CommonITILActor::REQUESTER)) {
$users = array();
foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
$uid = $tmpusr['users_id'];
$user_tmp = new User();
if ($uid && $user_tmp->getFromDB($uid)) {
$users[] = $user_tmp->getName();
$tmp = array();
$tmp['##author.id##'] = $uid;
$tmp['##author.name##'] = $user_tmp->getName();
if ($user_tmp->getField('locations_id')) {
$tmp['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id'));
} else {
$tmp['##author.location##'] = '';
}
if ($user_tmp->getField('usertitles_id')) {
$tmp['##author.title##'] = Dropdown::getDropdownName('glpi_usertitles', $user_tmp->getField('usertitles_id'));
} else {
$tmp['##author.title##'] = '';
}
if ($user_tmp->getField('usercategories_id')) {
$tmp['##author.category##'] = Dropdown::getDropdownName('glpi_usercategories', $user_tmp->getField('usercategories_id'));
} else {
$tmp['##author.category##'] = '';
}
$tmp['##author.email##'] = $user_tmp->getDefaultEmail();
$tmp['##author.mobile##'] = $user_tmp->getField('mobile');
$tmp['##author.phone##'] = $user_tmp->getField('phone');
$tmp['##author.phone2##'] = $user_tmp->getField('phone2');
$datas['authors'][] = $tmp;
} else {
// Anonymous users only in xxx.authors, not in authors
$users[] = $tmpusr['alternative_email'];
}
}
$datas["##{$objettype}.authors##"] = implode(', ', $users);
}
$datas["##{$objettype}.openbyuser##"] = '';
if ($item->getField('users_id_recipient')) {
$user_tmp = new User();
$user_tmp->getFromDB($item->getField('users_id_recipient'));
$datas["##{$objettype}.openbyuser##"] = $user_tmp->getName();
}
$datas["##{$objettype}.lastupdater##"] = '';
if ($item->getField('users_id_lastupdater')) {
$user_tmp = new User();
$user_tmp->getFromDB($item->getField('users_id_lastupdater'));
$datas["##{$objettype}.lastupdater##"] = $user_tmp->getName();
}
$datas["##{$objettype}.assigntousers##"] = '';
if ($item->countUsers(CommonITILActor::ASSIGN)) {
$users = array();
foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
$uid = $tmp['users_id'];
$user_tmp = new User();
if ($user_tmp->getFromDB($uid)) {
//.........这里部分代码省略.........
示例15: getDatasForObject
/**
* @param $item CommonDBTM object
* @param $options array
* @param $simple (false by default)
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI, $DB;
$objettype = strtolower($item->getType());
$datas["##{$objettype}.title##"] = $item->getField('name');
$datas["##{$objettype}.content##"] = $item->getField('content');
$datas["##{$objettype}.description##"] = $item->getField('content');
$datas["##{$objettype}.id##"] = sprintf("%07d", $item->getField("id"));
$datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id"));
$datas["##{$objettype}.urlapprove##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . '$2');
$entity = new Entity();
if ($entity->getFromDB($this->getEntity())) {
$datas["##{$objettype}.entity##"] = $entity->getField('completename');
$datas["##{$objettype}.shortentity##"] = $entity->getField('name');
}
$datas["##{$objettype}.storestatus##"] = $item->getField('status');
$datas["##{$objettype}.status##"] = $item->getStatus($item->getField('status'));
$datas["##{$objettype}.urgency##"] = $item->getUrgencyName($item->getField('urgency'));
$datas["##{$objettype}.impact##"] = $item->getImpactName($item->getField('impact'));
$datas["##{$objettype}.priority##"] = $item->getPriorityName($item->getField('priority'));
$datas["##{$objettype}.time##"] = $item->getActionTime($item->getField('actiontime'));
$datas["##{$objettype}.creationdate##"] = Html::convDateTime($item->getField('date'));
$datas["##{$objettype}.closedate##"] = Html::convDateTime($item->getField('closedate'));
$datas["##{$objettype}.solvedate##"] = Html::convDateTime($item->getField('solvedate'));
$datas["##{$objettype}.duedate##"] = Html::convDateTime($item->getField('due_date'));
$datas["##{$objettype}.category##"] = '';
if ($item->getField('itilcategories_id')) {
$datas["##{$objettype}.category##"] = Dropdown::getDropdownName('glpi_itilcategories', $item->getField('itilcategories_id'));
}
$datas["##{$objettype}.authors##"] = '';
$datas['authors'] = array();
if ($item->countUsers(CommonITILActor::REQUESTER)) {
$users = array();
foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
$uid = $tmpusr['users_id'];
$user_tmp = new User();
if ($uid && $user_tmp->getFromDB($uid)) {
$users[] = $user_tmp->getName();
$tmp = array();
$tmp['##author.id##'] = $uid;
$tmp['##author.name##'] = $user_tmp->getName();
if ($user_tmp->getField('locations_id')) {
$tmp['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id'));
} else {
$tmp['##author.location##'] = '';
}
if ($user_tmp->getField('usertitles_id')) {
$tmp['##author.title##'] = Dropdown::getDropdownName('glpi_usertitles', $user_tmp->getField('usertitles_id'));
} else {
$tmp['##author.title##'] = '';
}
if ($user_tmp->getField('usercategories_id')) {
$tmp['##author.category##'] = Dropdown::getDropdownName('glpi_usercategories', $user_tmp->getField('usercategories_id'));
} else {
$tmp['##author.category##'] = '';
}
$tmp['##author.email##'] = $user_tmp->getDefaultEmail();
$tmp['##author.mobile##'] = $user_tmp->getField('mobile');
$tmp['##author.phone##'] = $user_tmp->getField('phone');
$tmp['##author.phone2##'] = $user_tmp->getField('phone2');
$datas['authors'][] = $tmp;
} else {
// Anonymous users only in xxx.authors, not in authors
$users[] = $tmpusr['alternative_email'];
}
}
$datas["##{$objettype}.authors##"] = implode(', ', $users);
}
$datas["##{$objettype}.openbyuser##"] = '';
if ($item->getField('users_id_recipient')) {
$user_tmp = new User();
$user_tmp->getFromDB($item->getField('users_id_recipient'));
$datas["##{$objettype}.openbyuser##"] = $user_tmp->getName();
}
$datas["##{$objettype}.lastupdater##"] = '';
if ($item->getField('users_id_lastupdater')) {
$user_tmp = new User();
$user_tmp->getFromDB($item->getField('users_id_lastupdater'));
$datas["##{$objettype}.lastupdater##"] = $user_tmp->getName();
}
$datas["##{$objettype}.assigntousers##"] = '';
if ($item->countUsers(CommonITILActor::ASSIGN)) {
$users = array();
foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
$uid = $tmp['users_id'];
$user_tmp = new User();
if ($user_tmp->getFromDB($uid)) {
$users[$uid] = $user_tmp->getName();
}
}
$datas["##{$objettype}.assigntousers##"] = implode(', ', $users);
}
$datas["##{$objettype}.assigntosupplier##"] = '';
if ($item->countSuppliers(CommonITILActor::ASSIGN)) {
$suppliers = array();
//.........这里部分代码省略.........