예제 #1
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginBadgesBadge') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $badge = new PluginBadgesBadge();
                         $badge->getFromDB($key);
                         $type = PluginBadgesBadgeType::transfer($badge->fields["plugin_badges_badgetypes_id"], $input['entities_id']);
                         if ($type > 0) {
                             $values["id"] = $key;
                             $values["plugin_badges_badgetypes_id"] = $type;
                             if ($badge->update($values)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($badge->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
예제 #2
0
 /**
  * Show list of items
  * 
  * @param type $fields
  */
 function listItems($requesters_id, $options = array())
 {
     $params['begin_date'] = "NULL";
     $params['end_date'] = "NULL";
     foreach ($options as $key => $val) {
         $params[$key] = $val;
     }
     $data = $this->find('`requesters_id` = ' . $requesters_id . " " . "AND `affectation_date` >= '" . $params['begin_date'] . "' " . "AND (`return_date` <= '" . $params['end_date'] . "' OR `return_date` IS NULL)", "`affectation_date` DESC");
     $message = null;
     if (!empty($data)) {
         $message .= "<table class='tab_cadre_fixe'>";
         $message .= "<tr>";
         $message .= "<th colspan='6'>" . __('Badge usage report', 'badges') . "</th>";
         $message .= "</tr>";
         $message .= "<tr>";
         $message .= "<th>" . _n('Badge', 'Badges', 1, 'badge') . "</th>";
         $message .= "<th>" . __('Visitor realname', 'badges') . "</th>";
         $message .= "<th>" . __('Visitor firstname', 'badges') . "</th>";
         $message .= "<th>" . __('Visitor society', 'badges') . "</th>";
         $message .= "<th>" . __('Arrival date', 'badges') . "</th>";
         $message .= "<th>" . __('Return date', 'badges') . "</th>";
         $message .= "</tr>";
         $badge = new PluginBadgesBadge();
         foreach ($data as $field) {
             $message .= "<tr class='tab_bg_1'>";
             $badge->getFromDB($field['badges_id']);
             $message .= "<td>" . $badge->getLink() . "</td>";
             $message .= "<td>" . stripslashes($field['visitor_realname']) . "</td>";
             $message .= "<td>" . stripslashes($field['visitor_firstname']) . "</td>";
             $message .= "<td>" . stripslashes($field['visitor_society']) . "</td>";
             $message .= "<td>" . Html::convDateTime($field['affectation_date']) . "</td>";
             $message .= "<td>" . Html::convDateTime($field['return_date']) . "</td>";
             $message .= "</tr>";
         }
         $message .= "</table>";
         $message .= "</div>";
     } else {
         $message .= "<div class='center'>";
         $message .= "<table class='tab_cadre_fixe'>";
         $message .= "<tr>";
         $message .= "<th colspan='6'>" . __('Badge usage report', 'badges') . "</th>";
         $message .= "</tr>";
         $message .= "<tr><td class='center'>" . __('No item found') . "</td></tr>";
         $message .= "</table>";
     }
     return array('success' => true, 'message' => $message);
 }