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


PHP Reservation::add方法代码示例

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


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

示例1: ksort

 ksort($dates_to_add);
 if (count($dates_to_add) && count($_POST['items']) && isset($_POST['users_id'])) {
     foreach ($_POST['items'] as $reservationitems_id) {
         $input = array();
         $input['reservationitems_id'] = $reservationitems_id;
         $input['comment'] = $_POST['comment'];
         if (count($dates_to_add)) {
             $input['group'] = $rr->getUniqueGroupFor($reservationitems_id);
         }
         foreach ($dates_to_add as $begin => $end) {
             $input['begin'] = $begin;
             $input['end'] = $end;
             $input['users_id'] = $_POST['users_id'];
             if (Session::haveRight("reservation", UPDATE) || Session::getLoginUserID() === $input["users_id"]) {
                 unset($rr->fields["id"]);
                 if ($newID = $rr->add($input)) {
                     Event::log($newID, "reservation", 4, "inventory", sprintf(__('%1$s adds the reservation %2$s for item %3$s'), $_SESSION["glpiname"], $newID, $reservationitems_id));
                 } else {
                     $all_ok = false;
                 }
             }
         }
     }
 } else {
     $all_ok = false;
 }
 if ($all_ok) {
     $toadd = "";
     // Only one reservation : move to correct month
     if (count($_POST['items']) == 1) {
         $toadd = "?reservationitems_id={$reservationitems_id}";
开发者ID:stweil,项目名称:glpi,代码行数:31,代码来源:reservation.form.php

示例2: addReservation

/**  Generate bigdump : make an item reservable
 *
 * @param $type      item type
 * @param $ID        item ID
 * @param $ID_entity item entity ID
**/
function addReservation($type, $ID, $ID_entity) {
   global $percent, $DB, $FIRST, $LAST;

   $current_year = date("Y");

   if (mt_rand(0,100)<$percent['reservationitems']) {
      $ri  = new Reservationitem();
      $r   = new Reservation();
      $tID = $ri->add(toolbox::addslashes_deep(
                      array('itemtype'     => $type,
                            'entities_id'  => $ID_entity,
                            'is_recursive' => 0,
                            'items_id'     => $ID,
                            'comment'      => "comment ' $ID $type",
                            'is_active'    => 1)));

      $date1 = strtotime('-2 week'); // reservations since 2 weeks
      $date2 = $date1;
      $i     = 0;

      while (mt_rand(0,100)<$percent['reservations']) {
         $date1 = $date2+HOUR_TIMESTAMP*(1+mt_rand(0,10)); // min 10 hours between each resa max
         $date2 = $date1+HOUR_TIMESTAMP*mt_rand(1,10); // A reservation from 1 to 5 hours
//          echo $tID.' '.date("Y-m-d H:i:s", $date1).'->'.date("Y-m-d H:i:s", $date2).'<br>';
         $r->add(toolbox::addslashes_deep(
                 array('reservationitems_id' => $tID,
                       'begin'               => date("Y-m-d H:i:s", $date1),
                       'end'                 => date("Y-m-d H:i:s", $date2),
                       'users_id'            => mt_rand($FIRST['users_normal'],
                                                        $LAST['users_postonly']),
                       'comment'             => "comments '$i ".Toolbox::getRandomString(15))));
         $i++;
      }
   }
}
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:41,代码来源:generate_bigdump.function.php

示例3: list

     $times = $_POST["periodicity_times"];
     $begin = $_POST["begin"];
     list($begin_year, $begin_month, $begin_day) = explode("-", $_POST["begin"]);
     $end = $_POST["end"];
     $to_add = 1;
     if ($_POST["periodicity"] == "week") {
         $to_add = 7;
     }
     $_POST['_target'] = $_SERVER['PHP_SELF'];
     $_POST['_ok'] = true;
     for ($i = 0; $i < $times && $_POST['_ok']; $i++) {
         $_POST["begin"] = date('Y-m-d H:i:s', strtotime($begin) + $i * $to_add * DAY_TIMESTAMP);
         $_POST["end"] = date('Y-m-d H:i:s', strtotime($end) + $i * $to_add * DAY_TIMESTAMP);
         if (haveRight("reservation_central", "w") || getLoginUserID() === $_POST["users_id"]) {
             unset($rr->fields["id"]);
             $_POST['_ok'] = $rr->add($_POST);
         }
     }
     // Positionnement du calendrier au mois de debut
     $_GET["mois_courant"] = $begin_month;
     $_GET["annee_courant"] = $begin_year;
     if ($_POST['_ok']) {
         Event::log($_POST["reservationitems_id"], "reservation", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][20]);
     } else {
         $all_ok = false;
     }
 }
 if ($all_ok) {
     $toadd = "";
     // Only one reservation
     if (count($_POST['items']) == 1) {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:reservation.form.php


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