当前位置: 首页>>代码示例>>PHP>>正文


PHP Contract::add方法代码示例

本文整理汇总了PHP中Contract::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Contract::add方法的具体用法?PHP Contract::add怎么用?PHP Contract::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contract的用法示例。


在下文中一共展示了Contract::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: transferContracts

 /**
  * Transfer contracts
  *
  * @param $itemtype original type of transfered item
  * @param $ID original ID of the contract
  * @param $newID new ID of the contract
  **/
 function transferContracts($itemtype, $ID, $newID)
 {
     global $DB;
     $need_clean_process = false;
     // if keep
     if ($this->options['keep_contract']) {
         $contract = new Contract();
         // Get contracts for the item
         $query = "SELECT *\n                   FROM `glpi_contracts_items`\n                   WHERE `items_id` = '{$ID}'\n                         AND `itemtype` = '{$itemtype}'\n                         AND `contracts_id` NOT IN " . $this->item_recurs['Contract'];
         if ($result = $DB->query($query)) {
             if ($DB->numrows($result) > 0) {
                 // Foreach get item
                 while ($data = $DB->fetch_array($result)) {
                     $need_clean_process = false;
                     $item_ID = $data['contracts_id'];
                     $newcontractID = -1;
                     // is already transfer ?
                     if (isset($this->already_transfer['Contract'][$item_ID])) {
                         $newcontractID = $this->already_transfer['Contract'][$item_ID];
                         if ($newcontractID != $item_ID) {
                             $need_clean_process = true;
                         }
                     } else {
                         // No
                         // Can be transfer without copy ? = all linked items need to be transfer (so not copy)
                         $canbetransfer = true;
                         $query = "SELECT DISTINCT `itemtype`\n                               FROM `glpi_contracts_items`\n                               WHERE `contracts_id` = '{$item_ID}'";
                         if ($result_type = $DB->query($query)) {
                             if ($DB->numrows($result_type) > 0) {
                                 while (($data_type = $DB->fetch_array($result_type)) && $canbetransfer) {
                                     $dtype = $data_type['itemtype'];
                                     if (isset($this->item_search[$dtype])) {
                                         // No items to transfer -> exists links
                                         $query_search = "SELECT count(*) AS CPT\n                                                  FROM `glpi_contracts_items`\n                                                  WHERE `contracts_id` = '{$item_ID}'\n                                                        AND `itemtype` = '{$dtype}'\n                                                        AND `items_id`\n                                                             NOT IN " . $this->item_search[$dtype];
                                         $result_search = $DB->query($query_search);
                                         if ($DB->result($result_search, 0, 'CPT') > 0) {
                                             $canbetransfer = false;
                                         }
                                     } else {
                                         $canbetransfer = false;
                                     }
                                 }
                             }
                         }
                         // Yes : transfer
                         if ($canbetransfer) {
                             $this->transferItem('Contract', $item_ID, $item_ID);
                             $newcontractID = $item_ID;
                         } else {
                             $need_clean_process = true;
                             $contract->getFromDB($item_ID);
                             // No : search contract
                             $query = "SELECT *\n                                  FROM `glpi_contracts`\n                                  WHERE `entities_id` = '" . $this->to . "'\n                                        AND `name` = '" . addslashes($contract->fields['name']) . "'";
                             if ($result_search = $DB->query($query)) {
                                 if ($DB->numrows($result_search) > 0) {
                                     $newcontractID = $DB->result($result_search, 0, 'id');
                                     $this->addToAlreadyTransfer('Contract', $item_ID, $newcontractID);
                                 }
                             }
                             // found : use it
                             // not found : copy contract
                             if ($newcontractID < 0) {
                                 // 1 - create new item
                                 unset($contract->fields['id']);
                                 $input = $contract->fields;
                                 $input['entities_id'] = $this->to;
                                 unset($contract->fields);
                                 $newcontractID = $contract->add($input);
                                 // 2 - transfer as copy
                                 $this->transferItem('Contract', $item_ID, $newcontractID);
                             }
                         }
                     }
                     // Update links
                     if ($ID == $newID) {
                         if ($item_ID != $newcontractID) {
                             $query = "UPDATE `glpi_contracts_items`\n                                  SET `contracts_id` = '{$newcontractID}'\n                                  WHERE `id` = '" . $data['id'] . "'";
                             $DB->query($query);
                         }
                         // Same Item -> update links
                     } else {
                         // Copy Item -> copy links
                         if ($item_ID != $newcontractID) {
                             $query = "INSERT\n                                  INTO `glpi_contracts_items`\n                                  (`contracts_id`, `items_id`, `itemtype`)\n                                  VALUES ('{$newcontractID}', '{$newID}', '{$itemtype}')";
                             $DB->query($query);
                         } else {
                             // same contract for new item update link
                             $query = "UPDATE `glpi_contracts_items`\n                                  SET `items_id` = '{$newID}'\n                                  WHERE `id` = '" . $data['id'] . "'";
                             $DB->query($query);
                         }
                     }
                     // If clean and unused ->
                     if ($need_clean_process && $this->options['clean_contract']) {
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:transfer.class.php

示例2: generate_entity

/** Generate bigdump : generate items for an entity
 *
 * @param $ID_entity entity ID
**/
function generate_entity($ID_entity) {
   global $MAX, $DB, $percent, $FIRST, $LAST, $MAX_KBITEMS_BY_CAT, $MAX_DISK,
         $DOCUMENTS, $NET_PORT, $NET_LOC;

   regenerateTreeCompleteName("glpi_entities");

   $current_year = date("Y");


   // DOMAIN
   $items = array("SP2MI", "CAMPUS"," IUT86", "PRESIDENCE", "CEAT", "D'omaine");
   $dp    = new Domain();
   $FIRST["domain"] = getMaxItem("glpi_domains")+1;

   for ($i=0 ; $i<$MAX['domain'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "domain $ID_entity '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'         => $val,
                                              'entities_id'  => $ID_entity,
                                              'is_recursive' => 1,
                                              'comment'      => "comment $val")));
   }
   $LAST["domain"] = getMaxItem("glpi_domains");


   // STATUS
   $items = array("Reparation", "En stock", "En fonction", "Retour SAV", "En attente d'");
   $dp    = new State();
   $FIRST["state"] = getMaxItem("glpi_states")+1;
   for ($i=0 ; $i<$MAX['state'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "State $ID_entity '$i";
      }
      $state_id = $dp->add(toolbox::addslashes_deep(array('name'         => $val,
                                                          'entities_id'  => $ID_entity,
                                                          'is_recursive' => 1,
                                                          'comment'      => "comment $val")));

      // generate sub status
      for ($j=0 ; $j<$MAX['state'] ; $j++) {
         $val2 = "Sub $val $j";

         $dp->add(toolbox::addslashes_deep(array('name'         => $val2,
                                                 'entities_id'  => $ID_entity,
                                                 'is_recursive' => 1,
                                                 'states_id'    => $state_id,
                                                 'comment'      => "comment $val")));
      }

   }
   $LAST["state"]      = getMaxItem("glpi_states");


   // glpi_groups
   $FIRST["groups"] = getMaxItem("glpi_groups")+1;
   $group           = new Group();
   for ($i=0 ; $i<$MAX['groups'] ; $i++) {
      $gID = $group->add(toolbox::addslashes_deep(
                         array('entities_id'  => $ID_entity,
                               'name'         => "group d'$i",
                               'comment'      => "comment group d'$i",
                               'is_assign'    => 0)));

      // Generate sub group
      for ($j=0 ; $j<$MAX['groups'] ; $j++) {
         $group->add(toolbox::addslashes_deep(
                     array('entities_id'  => $ID_entity,
                           'name'         => "subgroup d'$j",
                           'comment'      => "comment subgroup d'$j of group $i",
                           'groups_id'    => $gID,
                           'is_assign'    => 0)));
      }
   }

   $LAST["groups"]      = getMaxItem("glpi_groups");

   $FIRST["techgroups"] = $LAST["groups"]+1;

   for ($i=0 ; $i<$MAX['groups'] ; $i++) {
         $group->add(toolbox::addslashes_deep(
                     array('entities_id'  => $ID_entity,
                           'name'         => "tech group d'$i",
                           'comment'      => "comment tech group d'$i")));
   }

   $LAST["techgroups"] = getMaxItem("glpi_groups");
   regenerateTreeCompleteName("glpi_groups");


   // glpi_users
   $FIRST["users_sadmin"] = getMaxItem("glpi_users")+1;
//.........这里部分代码省略.........
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:101,代码来源:generate_bigdump.function.php

示例3: array

            $html .= '<td align=center><a href="' . edkuri::build(array(array('ctr_id', $ctrID, false), array('op', 'edit', false), array('sop', "del_{$type}", false), array('id', $contracttarget->getID(), false))) . '">delete</a></td></tr>';
        }
        if ($c < 30) {
            $html .= '<form id=add_target name=add_target method=post action="' . edkuri::build(array(array('ctr_id', $ctrID, false), array('op', 'edit', false))) . '">';
            $html .= "<tr><td></td></tr>";
            $html .= "<tr><td><input type=text id=add_name name=add_name size=30 maxlength=30></td><td align=center><input type=radio name=add_type id=add_type value=0 checked></td><td align=center><input type=radio name=add_type id=add_type value=1></td><td align=center><input type=radio name=add_type id=add_type value=2></td><td align=center><input type=radio name=add_type id=add_type value=3></td><td align=center><input type=submit id=submit name=submit value=Add></td></tr>";
        }
        $html .= "</table>";
        $html .= "</form>";
    }
}
// add
if (edkURI::getArg('op') == "add") {
    if ($_POST['detail_submit']) {
        $contract = new Contract();
        $contract->add($_POST['ctr_name'], $_POST['ctr_started'], $_POST['ctr_ended'], $_POST['ctr_comment']);
        header("Location: " . htmlspecialchars_decode(edkuri::build(array(array('ctr_id', $contract->getID(), false), array('op', 'edit', false)))));
    }
    $page->setTitle("Administration - Add Campaign");
    $html .= "<div class=block-header2>Details</div>";
    $html .= '<form id=detail_edit name=detail_edit method=post action="' . edkuri::build(array(array('ctr_id', $ctrID, false), array('op', 'add', false))) . '">';
    $html .= "<table class=kb-table width=98%>";
    $html .= "<tr><td width=80><b>Name:</b></td><td><input type=text name=ctr_name id=ctr_name size=40 maxlength=40></td></tr>";
    $html .= "<tr><td width=80><b>Start date:</b></td><td><input type=text name=ctr_started id=ctr_started size=10 maxlength=10 value=\"" . kbdate("Y-m-d") . "\"> (yyyy-mm-dd)</td></tr>";
    $html .= "<tr><td width-80><b>End date:</b></td><td><input type=text name=ctr_ended id=ctr_ended size=10 maxlength=10> (yyyy-mm-dd or blank)</td></tr>";
    $html .= "<tr><td><b>Comment:</b></td><td><input type='text' name='ctr_comment' size='100'/></td></tr>";
    $html .= "<tr><td></td></tr>";
    $html .= "<tr><td></td><td><input type=submit name=detail_submit value=\"Save\"></td></tr>";
    $html .= "</table>";
    $html .= "</form>";
}
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:31,代码来源:admin_cc.php

示例4: Contract

* @brief
*/
include '../inc/includes.php';
Session::checkRight("contract", "r");
if (!isset($_GET["id"])) {
    $_GET["id"] = -1;
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$contract = new Contract();
$contractitem = new Contract_Item();
$contractsupplier = new Contract_Supplier();
if (isset($_POST["add"])) {
    $contract->check(-1, 'w', $_POST);
    if ($newID = $contract->add($_POST)) {
        Event::log($newID, "contracts", 4, "financial", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $contract->check($_POST['id'], 'd');
        if ($contract->delete($_POST)) {
            Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        }
        $contract->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $contract->check($_POST['id'], 'd');
            if ($contract->restore($_POST)) {
                Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:contract.form.php


注:本文中的Contract::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。