The followings are the available columns in table 'transfer':
Inheritance: extends HMSActiveRecord
Example #1
0
 public function action_changeShort()
 {
     echo 'test2';
     return;
     $member = \MemberQuery::create()->findOneById(1);
     $con = \Propel::getConnection();
     if (!$con->beginTransaction()) {
         throw new \Exception('Could not begin transaction');
     }
     try {
         $transfer = \TransferQuery::create()->findOneById(1);
         if (!$transfer) {
             $transfer = new \Transfer();
             $transfer->setMemberId($member->getId());
             $transfer->save($con);
             $transfer = \TransferQuery::create()->findOneById(1);
         }
         $transfer->setAmount($transfer->getAmount() + 2);
         $transfer->save($con);
         if (!$con->commit()) {
             throw new \Exception('Could not commit transaction');
         }
     } catch (\Exception $e) {
         $con->rollBack();
         throw $e;
     }
     print_r('<pre>');
     print_r($transfer->toArray());
     print_r('</pre>');
 }
 public function display()
 {
     // Cancel the transfer if a request is submitted.
     if (isset($_POST['cancel'])) {
         $transfer = new Transfer();
         $transfer->cancelSessions();
         unset($_POST['cancel']);
         $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
         $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
         header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "New-Funds-Transfer");
         // Otherwise process the transfer.
     } elseif (isset($_POST['submit'])) {
         unset($_POST['submit']);
         // To negate any back button issues.
         if (!isset($_SESSION['transferDate']) || !isset($_SESSION['transferDescription']) || !isset($_SESSION['transferRemitter']) || !isset($_SESSION['transferAmount'])) {
             header('Location: New-Funds-Transfer');
         }
         if (isset($_POST['password'])) {
             $validate = new Validation();
             // Validate the password.
             try {
                 $validate->password($_POST['password']);
             } catch (ValidationException $e) {
                 $_SESSION['error'] = $e->getError();
             }
             if (isset($_SESSION['error'])) {
                 unset($_POST['password']);
                 header('Location: New-Funds-Transfer');
             } else {
                 $user = new Users();
                 $user->userID = $_SESSION['userID'];
                 $user->password = $_POST['password'];
                 unset($_POST['password']);
                 // Confirm the password is corredt.
                 try {
                     $user->confirmPassword();
                 } catch (ValidationException $e) {
                     $_SESSION['error'] = $e->getError();
                 }
                 if (isset($_SESSION['error'])) {
                     header('Location: New-Funds-Transfer');
                 } else {
                     // If everything is ok, process the transfer and display
                     // the Transfer Acknowledgement Page
                     $account = new Account();
                     $account->accountID = $_SESSION['transferAccountID'];
                     if ($account->processTransfer()) {
                         include 'view/layout/transferack.php';
                     } else {
                         // Otherwise return to the Check Transfer page.
                         $checkTransfer = new CheckTransfer();
                         $checkTransfer->init();
                         include 'view/layout/checktransfer.php';
                     }
                 }
             }
         }
     }
 }
Example #3
0
 /**
  * @see Application::initialize()
  */
 public function initialize(Transfer $transfer)
 {
     $template = new Template('');
     $template->baseUrl = dirname($transfer->server('PHP_SELF'));
     if ($template->baseUrl != '/') {
         $template->baseUrl = $template->baseUrl . '/';
     }
     $transfer->baseTpl = $template;
     $transfer->layout = $template->derive($this->getTemplatesPath() . 'layout.phtml');
 }
Example #4
0
 public function sendContactMail($name, $email, $message, $transferId, $hiddenMessage, $title)
 {
     if ($hiddenMessage == "" && isset($title)) {
         $transfer = new Transfer();
         $transferInfo = $transfer->getTransferById($transferId);
         $mailMessage = $this->createMailMessage($name, $email, $message, $transferInfo);
         $betreff = "Nachricht von Dhamma-Reise";
         $header = 'From: dhamma-reise@edelbyte.de' . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'Content-Type:text/plain" \\r\\n' . 'X-Mailer: PHP/' . phpversion();
         $this->debug("NEW MAIL MESSAGE", "Sending mail to: " . $transferInfo['email'] . "\n" . $betreff . $mailMessage);
         mail($transferInfo['email'], $betreff, $mailMessage, $header, "-f dhamma-reise@edelbyte.de");
     }
 }
Example #5
0
 /**
  * Get API URL for this Stripe transfer reversal.
  *
  * @throws \Arcanedev\Stripe\Exceptions\InvalidRequestException
  *
  * @return string
  */
 public function instanceUrl()
 {
     if (is_null($id = $this['id'])) {
         throw new InvalidRequestException('Could not determine which URL to request: class instance has invalid ID [null]', null);
     }
     return implode('/', [Transfer::classUrl(), urlencode(str_utf8($this['transfer'])), 'reversals', urlencode(str_utf8($id))]);
 }
Example #6
0
 public function testAllCharge()
 {
     self::authorizeFromEnv();
     $transfers = Transfer::all(array('limit' => 3, 'offset' => 0));
     if (count($transfers['data'])) {
         $transfer = Transfer::retrieve($transfers['data'][0]->id);
         $charges = $transfer->charges->all(array('limit' => 3, 'offset' => 0));
     }
 }
Example #7
0
 /**
  * @param array|null $params
  *
  * @return Collection of the Recipient's Transfers
  */
 public function transfers($params = null)
 {
     if ($params === null) {
         $params = array();
     }
     $params['recipient'] = $this->id;
     $transfers = Transfer::all($params, $this->_opts);
     return $transfers;
 }
Example #8
0
 public function testTransferUpdateMetadataAll()
 {
     $recipient = self::createTestRecipient();
     self::authorizeFromEnv();
     $transfer = Transfer::create(array('amount' => 100, 'currency' => 'usd', 'recipient' => $recipient->id));
     $transfer->metadata = array('test' => 'foo bar');
     $transfer->save();
     $updatedTransfer = Transfer::retrieve($transfer->id);
     $this->assertSame('foo bar', $updatedTransfer->metadata['test']);
 }
 /**
  * @return string The API URL for this Stripe transfer reversal.
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     $transfer = $this['transfer'];
     if (!$id) {
         throw new Error\InvalidRequest("Could not determine which URL to request: " . "class instance has invalid ID: {$id}", null);
     }
     $id = Util\Util::utf8($id);
     $transfer = Util\Util::utf8($transfer);
     $base = Transfer::classUrl();
     $transferExtn = urlencode($transfer);
     $extn = urlencode($id);
     return "{$base}/{$transferExtn}/reversals/{$extn}";
 }
Example #10
0
 function do_transfer(&$data)
 {
     eval(parent::do_transfer());
     include XOOPS_ROOT_PATH . "/header.php";
     xoops_loadLanguage('admin', 'spotlight');
     $page_handler =& xoops_getmodulehandler('page', 'spotlight');
     $page_obj =& $page_handler->create();
     $var_arr = array('page_title' => $data["title"], 'page_desc' => $data["summary"], 'page_link' => $data["url"], 'id' => $data["id"]);
     $page_obj->assignVars($var_arr);
     $form = $page_obj->getForm($this->config["url"]);
     $form->display();
     include XOOPS_ROOT_PATH . "/footer.php";
     exit;
 }
 /**
  * Print the config form for restrictions
  *
  * @return Nothing (display)
  **/
 function showFormInventory()
 {
     global $DB, $CFG_GLPI;
     if (!self::canView()) {
         return false;
     }
     $canedit = Config::canUpdate();
     if ($canedit) {
         echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     }
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('Assets') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td width='30%'>" . __('Enable the financial and administrative information by default') . "</td>";
     echo "<td  width='20%'>";
     Dropdown::ShowYesNo('auto_create_infocoms', $CFG_GLPI["auto_create_infocoms"]);
     echo "</td><td width='20%'> " . __('Restrict monitor management') . "</td>";
     echo "<td width='30%'>";
     $this->dropdownGlobalManagement("monitors_management_restrict", $CFG_GLPI["monitors_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Software category deleted by the dictionary rules') . "</td><td>";
     SoftwareCategory::dropdown(array('value' => $CFG_GLPI["softwarecategories_id_ondelete"], 'name' => "softwarecategories_id_ondelete"));
     echo "</td><td> " . __('Restrict device management') . "</td><td>";
     $this->dropdownGlobalManagement("peripherals_management_restrict", $CFG_GLPI["peripherals_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Beginning of fiscal year') . "</td><td>";
     Html::showDateField("date_tax", array('value' => $CFG_GLPI["date_tax"], 'maybeempty' => false, 'canedit' => true, 'min' => '', 'max' => '', 'showyear' => false));
     echo "</td><td> " . __('Restrict phone management') . "</td><td>";
     $this->dropdownGlobalManagement("phones_management_restrict", $CFG_GLPI["phones_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Automatic fields (marked by *)') . "</td><td>";
     $tab = array(0 => __('Global'), 1 => __('By entity'));
     Dropdown::showFromArray('use_autoname_by_entity', $tab, array('value' => $CFG_GLPI["use_autoname_by_entity"]));
     echo "</td><td> " . __('Restrict printer management') . "</td><td>";
     $this->dropdownGlobalManagement("printers_management_restrict", $CFG_GLPI["printers_management_restrict"]);
     echo "</td></tr>";
     echo "</table>";
     if (Session::haveRightsOr("transfer", array(CREATE, UPDATE)) && Session::isMultiEntitiesMode()) {
         echo "<br><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . __('Automatic transfer of computers') . "</th></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Template for the automatic transfer of computers in another entity') . "</td><td>";
         Transfer::dropdown(array('value' => $CFG_GLPI["transfers_id_auto"], 'name' => "transfers_id_auto", 'emptylabel' => __('No automatic transfer')));
         echo "</td></tr>";
         echo "</table>";
     }
     echo "<br><table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='4'>" . __('Automatically update of the elements related to the computers');
     echo "</th><th colspan='2'>" . __('Unit management') . "</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th>" . __('Alternate username') . "</th>";
     echo "<th>" . __('User') . "</th>";
     echo "<th>" . __('Group') . "</th>";
     echo "<th>" . __('Location') . "</th>";
     echo "<th>" . __('Status') . "</th>";
     echo "</tr>";
     $fields = array("contact", "user", "group", "location");
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('When connecting or updating') . "</td>";
     $values[0] = __('Do not copy');
     $values[1] = __('Copy');
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoupdate";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoupdate_mode", __('Copy computer status'), $CFG_GLPI["state_autoupdate_mode"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('When disconnecting') . "</td>";
     $values[0] = __('Do not delete');
     $values[1] = __('Clear');
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoclean";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoclean_mode", __('Clear status'), $CFG_GLPI["state_autoclean_mode"]);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='6' class='center'>";
         echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
         echo "</td></tr>";
     }
     echo "</table></div>";
     Html::closeForm();
 }
 /**
  * Update computer to not change entity (transfer not allowed)
  *
  * @test
  */
 public function updateComputerNoTranfer()
 {
     global $DB;
     $DB->connect();
     $transfer = new Transfer();
     $computer = new Computer();
     $pfiComputerInv = new PluginFusioninventoryInventoryComputerInventory();
     $pfEntity = new PluginFusioninventoryEntity();
     // Manual transfer computer to entity 2
     $transfer->getFromDB(1);
     $item_to_transfer = array("Computer" => array(1 => 1));
     $transfer->moveItems($item_to_transfer, 2, $transfer->fields);
     $computer->getFromDB(1);
     $this->assertEquals(2, $computer->fields['entities_id'], 'Transfer move computer');
     $this->AgentEntity(1, 2, 'Transfer computer on entity 2');
     // Define entity 2 not allowed to transfer
     $ents_id = $pfEntity->add(array('entities_id' => 2, 'transfers_id_auto' => 0));
     $this->assertEquals(2, $ents_id, 'Entity 2 defined with no transfer');
     // Update computer and computer must not be transfered (keep in entoty 2)
     $a_inventory = array();
     $a_inventory['CONTENT']['HARDWARE'] = array('NAME' => 'pc1');
     $a_inventory['CONTENT']['BIOS'] = array('SSN' => 'xxyyzz');
     $pfiComputerInv->import("pc-2013-02-13", "", $a_inventory);
     // Update
     $this->assertEquals(1, countElementsInTable('glpi_computers'), 'Must have only 1 computer');
     $computer->getFromDB(1);
     $this->assertEquals(2, $computer->fields['entities_id'], 'Computer must not be transfered');
     $this->AgentEntity(1, 2, 'Agent must stay with entity 2');
 }
  static public function retrieveByClient($status, $client_id = null)
  {
//echo $status;
    $types= array('all','sell','purchase','switch');
    $statuses= array('all','pending','completed','cancelled');    
    if(!in_array($status,$statuses))
    if(!in_array($status,$types))    
      die('Wrong status when getting transfer collection!');
    $IsTypeOriented = in_array($status,$statuses) ? false: true;
    if(!$client_id)
      die('Should add case for all clients!');


    $transactions= array();
    if($IsTypeOriented)
      $addition = ($status!= 'all') ? " AND types = '$status'" : "";
    else
      $addition = ($status!= 'all') ? " AND status = '$status'" : "";
      
    $query = " SELECT t.id, t.created_at, t.comment, a.name aname, i.fund_name name,
    i.ISIN code, t.status, t.types, t.amount, t.trade_date, t.settlement_date
    FROM transfers t, custody_ac a, fund i
    WHERE t.id_client = '$client_id' AND a.id = t.id_custody1 AND i.id = t.id_isin $addition ";
    
    $qres=mysql_query($query) or die(mysql_error());
    while($row=mysql_fetch_assoc($qres))
    {

      $transfer = new Transfer();
      $transfer->setId($row['id']);
      $transfer->setStatus($row['status']);
      $transfer->setType($row['types']);
      $transfer->setComment($row['comment']);
      $transfer->setSecurity($row['name']);
      $transfer->setAmount($row['amount']);
      $transfer->setIsin($row['code']);
      $transfer->setTradeDate($row['trade_date']);
      $transfer->setSettlementDate($row['settlement_date']);
      $transfer->setAccount($row['aname']);
      $transfer->setCreatedAt($row['created_at']);
      $transfers[] = $transfer;

    }

    return $transfers;
  }
Example #14
0
 public function doOldImport()
 {
     DB::delete('DELETE FROM `cache`');
     // delete old data:
     foreach (Auth::user()->accounts()->get() as $acc) {
         $acc->delete();
     }
     foreach (Auth::user()->budgets()->get() as $b) {
         $b->delete();
     }
     foreach (Auth::user()->categories()->get() as $b) {
         $b->delete();
     }
     foreach (Auth::user()->beneficiaries()->get() as $b) {
         $b->delete();
     }
     foreach (Icon::get() as $icon) {
         $icon->delete();
     }
     $data = file_get_contents('http://commondatastorage.googleapis.com/nder/import.json');
     $json = json_decode($data);
     $map = array();
     $map['accounts'] = array();
     $map['icons'] = array();
     // all accounts:
     foreach ($json->accounts as $account) {
         $newAccount = new Account();
         $newAccount->name = Crypt::encrypt($account->name);
         $newAccount->balance = floatval($account->balance);
         $newAccount->fireflyuser_id = Auth::user()->id;
         $newAccount->date = $account->date;
         $newAccount->save();
         $map['accounts'][$account->id] = $newAccount->id;
     }
     // all icons:
     foreach ($json->icons as $icon) {
         $newIcon = new Icon();
         $newIcon->file = $icon->file;
         $newIcon->save();
         $map['icons'][intval($icon->id)] = $newIcon->id;
     }
     // all beneficiaries:
     foreach ($json->beneficiaries as $ben) {
         $nb = new Beneficiary();
         $nb->fireflyuser_id = Auth::user()->id;
         $nb->name = Crypt::encrypt($ben->name);
         $nb->save();
         $map['beneficiaries'][$ben->id] = $nb->id;
     }
     // all budgets
     foreach ($json->budgets as $bd) {
         $nbg = new Budget();
         $nbg->fireflyuser_id = Auth::user()->id;
         $nbg->name = Crypt::encrypt($bd->name);
         $nbg->date = $bd->date;
         $nbg->amount = floatval($bd->amount);
         $nbg->save();
         $map['budgets'][$bd->id] = $nbg->id;
     }
     // all categories:
     foreach ($json->categories as $c) {
         $nc = new Category();
         $nc->fireflyuser_id = Auth::user()->id;
         $nc->icon_id = intval($map['icons'][intval($c->icon_id)]);
         $nc->name = Crypt::encrypt($c->name);
         $nc->showtrend = intval($c->showtrend);
         $nc->save();
         $map['categories'][$c->id] = $nc->id;
     }
     foreach ($json->targets as $t) {
         $nt = new Target();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_id = $map['accounts'][$t->account_id];
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->duedate = $t->duedate;
         $nt->startdate = $t->startdate;
         $nt->save();
         $map['targets'][$t->id] = $nt->id;
     }
     foreach ($json->transactions as $t) {
         $nt = new Transaction();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_id = $map['accounts'][$t->account_id];
         $nt->budget_id = is_null($t->budget_id) ? NULL : intval($map['budgets'][$t->budget_id]);
         $nt->category_id = is_null($t->category_id) ? NULL : $map['categories'][$t->category_id];
         $nt->beneficiary_id = is_null($t->beneficiary_id) ? NULL : $map['beneficiaries'][$t->beneficiary_id];
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->date = $t->date;
         $nt->onetime = intval($t->onetime);
         $nt->save();
         $map['transactions'][$t->id] = $nt->id;
     }
     foreach ($json->transfers as $t) {
         $nt = new Transfer();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_from = $map['accounts'][$t->account_from];
         $nt->account_to = $map['accounts'][$t->account_to];
         $nt->category_id = is_null($t->category_id) ? NULL : $map['categories'][$t->category_id];
         $nt->budget_id = is_null($t->budget_id) ? NULL : intval($map['budgets'][$t->budget_id]);
         $nt->target_id = is_null($t->target_id) ? NULL : intval($map['targets'][$t->target_id]);
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->date = $t->date;
         $nt->save();
         $map['targets'][$t->id] = $nt->id;
     }
     //
     //var_dump($data);
     // create everything from this file.
     // we map the old id's to the new one to save problems.
     return 'Old data successfully imported.';
 }
Example #15
0
<?php

echo 'test1';
include dirname(__FILE__) . '/bootstrap.php';
$member = \MemberQuery::create()->findOneById(1);
$con = \Propel::getConnection();
if (!$con->beginTransaction()) {
    throw new \Exception('Could not begin transaction');
}
try {
    $transfer = \TransferQuery::create()->findOneById(1);
    if (!$transfer) {
        $transfer = new \Transfer();
        $transfer->setMemberId($member->getId());
        $transfer->save($con);
        $transfer = \TransferQuery::create()->findOneById(1);
    }
    $transfer->setAmount($transfer->getAmount() + 2);
    $transfer->save($con);
    if (!$con->commit()) {
        throw new \Exception('Could not commit transaction');
    }
} catch (\Exception $e) {
    $con->rollBack();
    throw $e;
}
print_r('<pre>');
print_r($transfer->toArray());
print_r('</pre>');
echo "\n CONSISTENCY 2\n";
Example #16
0
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Html::header(__('Transfer'), '', 'admin', 'rule', 'transfer');
$transfer = new Transfer();
$transfer->checkGlobal(READ);
if (isset($_POST['transfer'])) {
    if (isset($_SESSION['glpitransfer_list'])) {
        if (!Session::haveAccessToEntity($_POST['to_entity'])) {
            Html::displayRightError();
        }
        $transfer->moveItems($_SESSION['glpitransfer_list'], $_POST['to_entity'], $_POST);
        unset($_SESSION['glpitransfer_list']);
        echo "<div class='b center'>" . __('Operation successful') . "<br>";
        echo "<a href='central.php'>" . __('Back') . "</a></div>";
        Html::footer();
        exit;
    }
} else {
    if (isset($_POST['clear'])) {
 protected function renderContent()
 {
     //Get some pre value from URL
     //The type of the content we want to create
     $type = isset($_GET['type']) ? strtolower(trim($_GET['type'])) : '';
     //If it has guid, it means this is a translated version
     $guid = isset($_GET['guid']) ? strtolower(trim($_GET['guid'])) : '';
     //Get the list of Content Type
     $types = GxcHelpers::getAvailableContentType();
     //List of language that should exclude not to translate
     $lang_exclude = array();
     //List of translated versions
     $versions = array();
     //Available Terms for this Object Type
     $terms = array();
     //Selected Terms
     $selected_terms = array();
     //Get Term Order
     $term_orders = ConstantDefine::getTermOrder();
     //If $type is empty then redirect to choose content type page
     if ($type != '') {
         //Check if the type appear in content type Definition
         if (array_key_exists($type, $types)) {
             // If the guid is not empty, it means we are creating a translated version of a content
             // We will exclude the translated language and include the name of the translated content to $versions
             if ($guid != '') {
                 $temp_object = Object::model()->findAll('guid=:gid', array(':gid' => $guid));
                 if (count($temp_object) > 0) {
                     foreach ($temp_object as $obj) {
                         $lang_exclude[] = $obj->lang;
                         $langs = GxcHelpers::getAvailableLanguages();
                         $versions[] = $obj->object_name . ' - ' . $langs[$obj->lang]['name'];
                     }
                 }
             }
             //Import the Content Type Class
             Yii::import('common.content_type.' . $type . '.' . $types[$type]['class']);
             //Init the class
             $typeClassObj = new $types[$type]['class']();
             $content_resources = $typeClassObj->Resources();
             //We start to implement the checking Permission HERE
             $param_content_check = array();
             $data_content_check = array();
             $param_content_check['type'] = $type;
             if (GxcContentPermission::checkCreatePermission($param_content_check, $data_content_check, $typeClassObj->Permissions())) {
                 $param_content_check['new_content'] = true;
                 $content_status = GxcContentPermission::getContentStatus($param_content_check, $data_content_check, $typeClassObj->Permissions());
                 $model = new $types[$type]['class']();
                 // Uncomment the following line if AJAX validation is needed
                 // $this->performAjaxValidation($model);
                 $model->object_date = date('Y-m-d H:i:s');
                 $model->person = '';
                 $model->guid = $guid;
                 $get_languages = GxcHelpers::loadLanguageItems($lang_exclude);
                 $available_languages = array();
                 foreach ($get_languages as $key => $value) {
                     $available_languages[] = $key;
                 }
                 //Get available Taxonomy and Terms for this Object
                 $available_taxonomy = Taxonomy::model()->findAll(' type = :type AND lang IN (' . implode(',', $available_languages) . ') ', array(':type' => $type));
                 if ($available_taxonomy) {
                     foreach ($available_taxonomy as $t) {
                         $temp = array();
                         $temp['id'] = $t->taxonomy_id;
                         $temp['lang'] = $t->lang;
                         $temp['name'] = $t->name;
                         $temp['terms'] = array();
                         //Look for the Term Items belong to this Taxonomy
                         $list_terms = Term::model()->findAll(array('select' => '*', 'condition' => 'taxonomy_id=:id', 'order' => 't.parent ASC, t.order ASC', 'params' => array(':id' => $t->taxonomy_id)));
                         if ($list_terms) {
                             foreach ($list_terms as $term) {
                                 $temp_item['id'] = $term->term_id;
                                 $temp_item['name'] = CHtml::encode($term->name);
                                 $temp_item['parent'] = $term->parent;
                                 $temp['terms']['item_' . $term->term_id] = $temp_item;
                             }
                         }
                         $terms[$t->taxonomy_id] = $temp;
                     }
                 }
                 if (isset($_POST[$types[$type]['class']])) {
                     $model->attributes = $_POST[$types[$type]['class']];
                     //Convert the date time publish to timestamp
                     $model->object_date = strtotime($model->object_date);
                     $model->object_date_gmt = local_to_gmt($model->object_date);
                     //Check which button the User click To Send to person or group
                     $button = $_POST['which_button'];
                     $trans = new Transfer();
                     // Get the Terms that the User Choose
                     //
                     $post_terms = isset($_POST['terms']) ? $_POST['terms'] : array();
                     $selected_terms = array();
                     if (!empty($post_terms)) {
                         foreach ($post_terms as $t) {
                             $t = explode('_', $t);
                             if (!isset($selected_terms[$t[1]])) {
                                 $selected_temp = array();
                                 $selected_temp['id'] = $terms[$t[1]]['id'];
                                 $selected_temp['lang'] = $terms[$t[1]]['lang'];
                                 $selected_temp['name'] = $terms[$t[1]]['name'];
                                 $selected_temp['terms']['item_' . $t[0]]['id'] = $t[0];
                                 $selected_temp['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                                 $selected_temp['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                                 $selected_temp['terms']['item_' . $t[0]]['data'] = $t[2];
                                 $selected_temp['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                                 $selected_terms[$t[1]] = $selected_temp;
                             } else {
                                 if (!isset($selected_terms['terms']['item_' . $t[0]])) {
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['id'] = $t[0];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data'] = $t[2];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                                 }
                             }
                         }
                     }
                     // After having the selected Terms, we need to make sure  all parents
                     // of the selected Terms must be added also
                     foreach ($selected_terms as $tx_key => $t) {
                         $array_parent_selected_terms = array();
                         foreach ($t['terms'] as $key => $st_terms) {
                             $current_term = $st_terms;
                             while ($current_term['parent'] != 0) {
                                 if (!isset($array_parent_selected_terms['item_' . $current_term['parent']]) && !isset($t['terms']['item_' . $current_term['parent']])) {
                                     $array_parent_selected_terms['item_' . $current_term['parent']] = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                                     $array_parent_selected_terms['item_' . $current_term['parent']]['data'] = key($term_orders);
                                     $array_parent_selected_terms['item_' . $current_term['parent']]['data_name'] = $term_orders[key($term_orders)];
                                 }
                                 $current_term = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                             }
                         }
                         $selected_terms[$tx_key]['terms'] = CMap::mergeArray($t['terms'], $array_parent_selected_terms);
                     }
                     //Re-Set the Status based on what User Chooose
                     //The content is sent to ROLES OR STATUS
                     if ($button == '1') {
                         //Check if the object_status is number or character
                         if (!is_numeric($model->object_status)) {
                             //Set the status to Pending
                             $trans->note = $model->object_status;
                             $model->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->type = ConstantDefine::TRANS_ROLE;
                             $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                         } else {
                             $trans->type = ConstantDefine::TRANS_STATUS;
                             $trans->after_status = $model->object_status;
                         }
                         $trans->from_user_id = user()->id;
                         $trans->to_user_id = 0;
                         $trans->before_status = ConstantDefine::OBJECT_STATUS_DRAFT;
                     }
                     //The content is sent to PERSON DIRECTLY
                     if ($button == '2') {
                         $to_user_id = User::findPeople($model->person);
                         //Start to Transfer to the user and set the status to Pending
                         if ($to_user_id) {
                             $model->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->from_user_id = user()->id;
                             $trans->to_user_id = $to_user_id->user_id;
                             $trans->type = ConstantDefine::TRANS_PERSON;
                             $trans->before_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                         } else {
                             $model->addError('person', t('User not found'));
                         }
                     }
                     //Work with Resource Binding
                     $resource = array();
                     $resource_upload = array();
                     foreach ($content_resources as $res) {
                         $resource_upload[] = GxcHelpers::getArrayResourceObjectBinding('resource_upload_' . $res['type']);
                     }
                     $i = 0;
                     $count_resource = 0;
                     foreach ($content_resources as $cres) {
                         $j = 1;
                         foreach ($resource_upload[$i] as $res_up) {
                             $j++;
                             $count_resource++;
                         }
                         $i++;
                     }
                     $model->total_number_resource = $count_resource;
                     if ($model->save()) {
                         user()->setFlash('success', t('cms', 'Create new Content Successfully!'));
                         $trans->object_id = $model->object_id;
                         $trans->save();
                         // We have all the selected Terms for now
                         // We will add them to Object Terms
                         foreach ($selected_terms as $tx_key => $t) {
                             foreach ($t['terms'] as $key => $st_terms) {
                                 $obj_term = new ObjectTerm();
                                 $obj_term->object_id = $model->object_id;
                                 $obj_term->term_id = $st_terms['id'];
                                 $obj_term->data = $st_terms['data'];
                                 $obj_term->save();
                                 unset($obj_term);
                             }
                         }
                         //Update Resource Binding Here
                         $i = 0;
                         $count_resource = 0;
                         foreach ($content_resources as $cres) {
                             $j = 1;
                             foreach ($resource_upload[$i] as $res_up) {
                                 $obj_res = new ObjectResource();
                                 $obj_res->resource_id = $res_up['resid'];
                                 $obj_res->object_id = $model->object_id;
                                 $obj_res->description = '';
                                 $obj_res->type = $cres['type'];
                                 $obj_res->resource_order = $j;
                                 $obj_res->save();
                                 $j++;
                                 $count_resource++;
                             }
                             $i++;
                         }
                         //Re-init new Model
                         $model = new $types[$type]['class']();
                         $model->object_date = date('Y-m-d H:i:s');
                         Yii::app()->controller->refresh();
                     } else {
                         $model->object_date = date('Y-m-d H:i:s', $model->object_date);
                     }
                 }
                 $render_template = 'cmswidgets.views.object.object_form_widget';
                 if (file_exists(Yii::getPathOfAlias('common.content_type.' . strtolower($type) . '.object_form_widget') . '.php')) {
                     $render_template = 'common.content_type.' . strtolower($type) . '.object_form_widget';
                 }
                 $this->render($render_template, array('model' => $model, 'versions' => $versions, 'lang_exclude' => $lang_exclude, 'content_status' => $content_status, 'terms' => $terms, 'selected_terms' => $selected_terms, 'type' => $type, 'content_resources' => $content_resources));
             }
         } else {
             //The type is not in Content Type Definition
             $this->render('cmswidgets.views.object.object_start_widget', array('types' => $types));
         }
     } else {
         //There is no Type in $_GET
         $this->render('cmswidgets.views.object.object_start_widget', array('types' => $types));
     }
 }
Example #18
0
 /**
  * Do automatic transfer if option is enable
  *
  * @param $line_links array : data from glpi_plugin_ocsinventoryng_ocslinks table
  * @param $line_ocs array : data from ocs tables
  *
  * @return nothing
  **/
 static function transferComputer($line_links, $line_ocs)
 {
     global $DB, $PluginOcsinventoryngDBocs, $CFG_GLPI;
     // Get all rules for the current plugin_ocsinventoryng_ocsservers_id
     $rule = new RuleImportEntityCollection();
     $data = array();
     $data = $rule->processAllRules(array('ocsservers_id' => $line_links["plugin_ocsinventoryng_ocsservers_id"], '_source' => 'ocsinventoryng'), array(), array('ocsid' => $line_links["ocsid"]));
     // If entity is changing move items to the new entities_id
     if (isset($data['entities_id']) && $data['entities_id'] != $line_links['entities_id']) {
         if (!isCommandLine() && !Session::haveAccessToEntity($data['entities_id'])) {
             Html::displayRightError();
         }
         $transfer = new Transfer();
         $transfer->getFromDB($CFG_GLPI['transfers_id_auto']);
         $item_to_transfer = array("Computer" => array($line_links['computers_id'] => $line_links['computers_id']));
         $transfer->moveItems($item_to_transfer, $data['entities_id'], $transfer->fields);
     }
     //If location is update by a rule
     self::updateLocation($line_links, $data);
 }
Example #19
0
 zum Anbieter einer Fahrt aufnehmen.<?php 
    } else {
        ?>
 zu einem Mitfahrer aufnehmen.<?php 
    }
    ?>
 Ihre Daten werden per E-Mail &uuml;bertragen und der Empf&auml;nger kann sich dann mit Ihnen in Verbindung setzen.<br />
  Die mit einem Sternchen gekennzeichneten Felder sind Pflichtfelder. </p>
        
  <div class="box">      
		<?php 
    $centre = new Centre();
    $centreName = $centre->getNameById($_GET['centreId']);
    $events = new Event();
    $eventInfo = $events->getEventById($_GET['eventId']);
    $transfer = new Transfer();
    $transferInfo = $transfer->getTransferById($transferId);
    if ($offers) {
        ?>
		<form action="contact.php?eventId=<?php 
        echo $_GET['eventId'];
        ?>
&centreId=<?php 
        echo $_GET['centreId'];
        ?>
&mode=offer&transferId=<?php 
        echo $_GET['transferId'];
        ?>
&<?php 
        echo SID;
        ?>
Example #20
0
 /**
  * Get the history workflow of the Object
  * @param type $object 
  */
 public static function getTransferHistory($model)
 {
     $trans = Transfer::model()->with('from_user')->findAll(array('condition' => ' object_id=:obj ', 'params' => array(':obj' => $model->object_id), 'order' => 'transfer_id ASC'));
     $trans_list = "<ul>";
     $trans_list .= "<li>- <b>" . $model->author->display_name . "</b> " . t("cms", "created on") . " <b>" . date('m/d/Y H:i:s', $model->object_modified) . "</b></li>";
     //Start to Translate all the Transition
     foreach ($trans as $tr) {
         if ($tr->type == ConstantDefine::TRANS_STATUS) {
             $temp = "<li>- <b>" . $tr->from_user->display_name . "</b> " . t("cms", "changed status to") . " <b>" . self::convertObjectStatus($tr->after_status) . "</b> " . t("cms", "on") . " <b>" . date('m/d/Y H:i:s', $tr->time) . "</b></li>";
         }
         if ($tr->type == ConstantDefine::TRANS_ROLE) {
             $temp = "<li>- <b>" . $tr->from_user->display_name . "</b> " . t("cms", "modified and sent to") . " <b>" . ucfirst($tr->note) . "</b> " . t("cms", "on") . " <b>" . date('m/d/Y H:i:s', $tr->time) . "</b></li>";
         }
         if ($tr->type == ConstantDefine::TRANS_PERSON) {
             $to_user = User::model()->findbyPk($tr->to_user_id);
             $name = "";
             if ($to_user != null) {
                 $name = $to_user->display_name;
             }
             $temp = "<li>- <b>" . $tr->from_user->display_name . "</b> " . t("cms", "modified and sent to") . " <b>" . ucfirst($name) . "</b> " . t("cms", "on") . " <b>" . date('m/d/Y H:i:s', $tr->time) . "</b></li>";
         }
         $trans_list .= $temp;
     }
     $trans_list .= '</ul>';
     return $trans_list;
 }
Example #21
0
 public function getAllotments()
 {
     //$applicant = $this->loadModel($id);
     $allotments = $this->allotments;
     // get all allotments made to this applicant
     if (!empty($allotments)) {
         // if allotment(s) was made
         $cnt = count($allotments);
         for ($i = 0; $i < $cnt; $i++) {
             //check if it was transferred to anyone else
             $criteria = new CDbCriteria(array('condition' => 'allotment_id=:aid', 'order' => 'transfer_date DESC', 'limit' => 1, 'params' => array(':aid' => $allotments[$i]->id)));
             $transfer = Transfer::model()->find($criteria);
             if ($transfer != null) {
                 //if transferred set $allotment date and deed_no
                 if ($transfer->applicant_id === $this->id) {
                     $allotments[$i]->date = $transfer->transfer_date;
                     $allotments[$i]->order_no = $transfer->deed_no;
                     $allotments[$i]->type = 'transfer';
                 } else {
                     unset($allotments[$i]);
                 }
             }
         }
     }
     //select allotments from transfers if any made only by transfer
     $criteria = new CDbCriteria(array('condition' => 'applicant_id=:aid', 'order' => 'transfer_date DESC', 'limit' => 1, 'params' => array(':aid' => $this->id)));
     $transfer = Transfer::model()->find($criteria);
     if ($transfer != null) {
         //if transferred set $allotment date and deed_no
         if ($transfer->applicant_id === $this->id) {
             $allotment = $transfer->allotment;
             $allotment->applicant_id = $transfer->applicant_id;
             $allotment->date = $transfer->transfer_date;
             $allotment->order_no = $transfer->deed_no;
             $allotment->type = 'transfer';
             $allotments[] = $allotment;
         }
     }
     return new CArrayDataProvider($allotments);
 }
Example #22
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTransfers()
 {
     return $this->hasMany(Transfer::className(), ['id_warehouse_dest' => 'id_warehouse']);
 }
Example #23
0
LICENSE

This file is part of GLPI.

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkRight("transfer", READ);
if (isset($_POST["id"]) && $_POST["id"] > 0) {
    $transfer = new Transfer();
    $transfer->showForm($_POST["id"], array('target' => $CFG_GLPI["root_doc"] . "/front/transfer.action.php"));
}
Html::ajaxFooter();
 protected function renderContent()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     $model = GxcHelpers::loadDetailModel('Object', $id);
     //We start to implement the checking Permission HERE
     $param_content_check = array();
     $data_content_check = array();
     $param_content_check['type'] = $model->object_type;
     $param_content_check['new_content'] = false;
     $param_content_check['content_status'] = $model->object_status;
     $param_content_check['content_author'] = $model->object_author;
     //Get current trans_to of the object
     $trans = Transfer::model()->findAll(array('condition' => ' object_id=:obj ', 'params' => array(':obj' => $model->object_id), 'order' => 'transfer_id DESC'));
     $param_content_check['check_trans_note'] = false;
     if ($trans != null && count($trans) > 0) {
         $latest_trans_to = $trans[0];
         $param_content_check['trans_type'] = $latest_trans_to->type;
         $param_content_check['trans_to'] = $latest_trans_to->to_user_id;
         $param_content_check['trans_note'] = $latest_trans_to->note;
     }
     //Get Types list and type of the Object
     $types = GxcHelpers::getAvailableContentType();
     $type = (string) $model->object_type;
     //Import the Content Type Class
     Yii::import('common.content_type.' . $type . '.' . $types[$type]['class']);
     $typeClassObj = new $types[$type]['class']();
     $content_resources = $typeClassObj->Resources();
     //Check if the User has the Permission to update the Content
     if (GxcContentPermission::checkUpdatePermission($param_content_check, $data_content_check, $typeClassObj->Permissions())) {
         //Convert the object date from timestamp to datetime format
         $model->object_date = date('Y-m-d H:i:s', $model->object_date);
         //Get available content Status that the Object can be sent to
         $content_status = GxcContentPermission::getContentStatus($param_content_check, $data_content_check, $typeClassObj->Permissions());
         //If the Object is Pending and being sent to someone, get that person info
         if ($model->object_status == ConstantDefine::OBJECT_STATUS_PENDING) {
             if ($latest_trans_to->type == ConstantDefine::TRANS_PERSON) {
                 $send_to_user = User::model()->findbyPk($latest_trans_to->to_user_id);
                 if ($send_to_user == null) {
                     $model->person = '';
                 } else {
                     $model->person = trim($send_to_user->display_name);
                 }
             }
         }
         //Unset value for Lang Exclude, Version and Guid when updating
         $lang_exclude = array();
         $versions = array();
         $guid = $model->guid;
         // Create new instance Object based on Object Type
         $object = new $types[$type]['class']();
         $object->person = $model->person;
         $object->setAttributes($model->attributes, false);
         // Get Extra Info - Object Meta of the Object Type
         $object_metas = ObjectMeta::model()->findAll('meta_object_id = :obj ', array(':obj' => $model->object_id));
         foreach ($object_metas as $object_meta) {
             $key = (string) $object_meta->meta_key;
             $object->{$key} = $object_meta->meta_value;
         }
         // This is not a new Record
         $object->isNewRecord = false;
         //Set current tags for Object
         $object->_oldTags = $object->tags;
         $object->scenario = 'updateWithTags';
         //Available Terms for this Object Type
         $terms = array();
         //Selected Terms
         $selected_terms = array();
         //Get Term Order
         $term_orders = ConstantDefine::getTermOrder();
         //Get available Taxonomy and Terms for this Object
         $available_taxonomy = Taxonomy::model()->findAll(' type = :type AND lang IN (' . $object->lang . ') ', array(':type' => $type));
         if ($available_taxonomy) {
             foreach ($available_taxonomy as $t) {
                 $temp = array();
                 $temp['id'] = $t->taxonomy_id;
                 $temp['lang'] = $t->lang;
                 $temp['name'] = $t->name;
                 $temp['terms'] = array();
                 $selected_temp = array();
                 $selected_temp['id'] = $t->taxonomy_id;
                 $selected_temp['lang'] = $t->lang;
                 $selected_temp['name'] = $t->name;
                 $selected_temp['terms'] = array();
                 //Look for the Term Items belong to this Taxonomy
                 $list_terms = Term::model()->findAll(array('select' => '*', 'condition' => 'taxonomy_id=:id', 'order' => 't.parent ASC, t.order ASC', 'params' => array(':id' => $t->taxonomy_id)));
                 if ($list_terms) {
                     foreach ($list_terms as $term) {
                         $temp_item['id'] = $term->term_id;
                         $temp_item['name'] = CHtml::encode($term->name);
                         $temp_item['parent'] = $term->parent;
                         $temp['terms']['item_' . $term->term_id] = $temp_item;
                     }
                 }
                 $terms[$t->taxonomy_id] = $temp;
                 //Look for selected Terms belong to this Taxonomy
                 $sl_terms = ObjectTerm::model()->findAll(array('select' => '*', 'condition' => 'object_id=:id', 'params' => array(':id' => $object->object_id)));
                 if ($sl_terms) {
                     foreach ($sl_terms as $sl_term) {
                         if (isset($terms[$t->taxonomy_id]['terms']['item_' . $sl_term->term_id])) {
                             $selected_temp['terms']['item_' . $sl_term->term_id] = $terms[$t->taxonomy_id]['terms']['item_' . $sl_term->term_id];
                             $selected_temp['terms']['item_' . $sl_term->term_id]['data'] = $sl_term->data;
                             $selected_temp['terms']['item_' . $sl_term->term_id]['data_name'] = $term_orders[$sl_term->data];
                         }
                     }
                 }
                 $selected_terms[$t->taxonomy_id] = $selected_temp;
             }
         }
         //IF having the Post Method - Start to working to save it
         if (isset($_POST[$types[$type]['class']])) {
             $object->attributes = $_POST[$types[$type]['class']];
             //Convert the date time publish to timestamp
             $object->object_date = strtotime($object->object_date);
             $object->object_date_gmt = local_to_gmt($object->object_date);
             //Check which button the User click To Send to person or group
             $button = $_POST['which_button'];
             $trans = new Transfer();
             // Get the Terms that the User Choose
             $post_terms = isset($_POST['terms']) ? $_POST['terms'] : array();
             $selected_terms = array();
             if (!empty($post_terms)) {
                 foreach ($post_terms as $t) {
                     $t = explode('_', $t);
                     if (!isset($selected_terms[$t[1]])) {
                         $selected_temp = array();
                         $selected_temp['id'] = $terms[$t[1]]['id'];
                         $selected_temp['lang'] = $terms[$t[1]]['lang'];
                         $selected_temp['name'] = $terms[$t[1]]['name'];
                         $selected_temp['terms']['item_' . $t[0]]['id'] = $t[0];
                         $selected_temp['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                         $selected_temp['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                         $selected_temp['terms']['item_' . $t[0]]['data'] = $t[2];
                         $selected_temp['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                         $selected_terms[$t[1]] = $selected_temp;
                     } else {
                         if (!isset($selected_terms['terms']['item_' . $t[0]])) {
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['id'] = $t[0];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data'] = $t[2];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                         }
                     }
                 }
             }
             // After having the selected Terms, we need to make sure  all parents
             // of the selected Terms must be added also
             foreach ($selected_terms as $tx_key => $t) {
                 $array_parent_selected_terms = array();
                 foreach ($t['terms'] as $key => $st_terms) {
                     $current_term = $st_terms;
                     while ($current_term['parent'] != 0) {
                         if (!isset($array_parent_selected_terms['item_' . $current_term['parent']]) && !isset($t['terms']['item_' . $current_term['parent']])) {
                             $array_parent_selected_terms['item_' . $current_term['parent']] = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                             $array_parent_selected_terms['item_' . $current_term['parent']]['data'] = key($term_orders);
                             $array_parent_selected_terms['item_' . $current_term['parent']]['data_name'] = $term_orders[key($term_orders)];
                         }
                         $current_term = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                     }
                 }
                 $selected_terms[$tx_key]['terms'] = CMap::mergeArray($t['terms'], $array_parent_selected_terms);
             }
             //Re-Set the Status based on what User Chooose
             //The content is sent to ROLES OR STATUS
             if ($button == '1') {
                 //Check if the object_status is number or character
                 if (!is_numeric($object->object_status)) {
                     //Set the status to Pending
                     $trans->note = $object->object_status;
                     $object->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->type = ConstantDefine::TRANS_ROLE;
                     $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                 } else {
                     $trans->type = ConstantDefine::TRANS_STATUS;
                     $trans->after_status = $object->object_status;
                 }
                 $trans->from_user_id = user()->id;
                 $trans->to_user_id = 0;
                 $trans->before_status = ConstantDefine::OBJECT_STATUS_DRAFT;
             }
             //The content is sent to PERSON DIRECTLY
             if ($button == '2') {
                 $to_user_id = User::findPeople($object->person);
                 //Start to Transfer to the user and set the status to Pending
                 if ($to_user_id) {
                     $object->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->from_user_id = user()->id;
                     $trans->to_user_id = $to_user_id->user_id;
                     $trans->type = ConstantDefine::TRANS_PERSON;
                     $trans->before_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                 } else {
                     $object->addError('person', t('User not found'));
                 }
             }
             //Work with Resource Binding
             $resource = array();
             $resource_upload = array();
             foreach ($content_resources as $res) {
                 $resource_upload[] = GxcHelpers::getArrayResourceObjectBinding('resource_upload_' . $res['type']);
             }
             $i = 0;
             $count_resource = 0;
             foreach ($content_resources as $cres) {
                 $j = 1;
                 foreach ($resource_upload[$i] as $res_up) {
                     $j++;
                     $count_resource++;
                 }
                 $i++;
             }
             $object->total_number_resource = $count_resource;
             if ($object->save()) {
                 user()->setFlash('success', t('cms', 'Update content Successfully!'));
                 $trans->object_id = $object->object_id;
                 $trans->save();
                 //This is the update process, we should delete old
                 //Object Term binding
                 ObjectTerm::model()->deleteAll('object_id = :id', array(':id' => $object->object_id));
                 // We have all the selected Terms for now
                 // We will add them to Object Terms
                 foreach ($selected_terms as $tx_key => $t) {
                     foreach ($t['terms'] as $key => $st_terms) {
                         $obj_term = new ObjectTerm();
                         $obj_term->object_id = $object->object_id;
                         $obj_term->term_id = $st_terms['id'];
                         $obj_term->data = $st_terms['data'];
                         $obj_term->save();
                         unset($obj_term);
                     }
                 }
                 //Re update for Resource
                 ObjectResource::model()->deleteAll('object_id = :id', array(':id' => $object->object_id));
                 $i = 0;
                 $count_resource = 0;
                 foreach ($content_resources as $cres) {
                     $j = 1;
                     foreach ($resource_upload[$i] as $res_up) {
                         $obj_res = new ObjectResource();
                         $obj_res->resource_id = $res_up['resid'];
                         $obj_res->object_id = $object->object_id;
                         $obj_res->description = '';
                         $obj_res->type = $cres['type'];
                         $obj_res->resource_order = $j;
                         $obj_res->save();
                         $j++;
                         $count_resource++;
                     }
                     $i++;
                 }
             }
             $object->object_date = date('Y-m-d H:i:s', $object->object_date);
         }
         //Start Render the Form
         $render_template = 'cmswidgets.views.object.object_form_widget';
         if (file_exists(Yii::getPathOfAlias('common.content_type.' . strtolower($type) . '.object_form_widget') . '.php')) {
             $render_template = 'common.content_type.' . strtolower($type) . '.object_form_widget';
         }
         $this->render($render_template, array('model' => $object, 'versions' => $versions, 'lang_exclude' => $lang_exclude, 'content_status' => $content_status, 'terms' => $terms, 'selected_terms' => $selected_terms, 'type' => $type, 'content_resources' => $content_resources));
     }
 }
Example #25
0
 /**
  * @param $create (true by default)
  * @return int
  */
 static function getUninstallTransferModelID($create = true)
 {
     global $DB;
     $iterator = $DB->request('glpi_transfers', "`name`='" . self::PLUGIN_UNINSTALL_TRANSFER_NAME . "'");
     if (!$iterator->numrows()) {
         if ($create) {
             $transfer = new Transfer();
             $input["name"] = self::PLUGIN_UNINSTALL_TRANSFER_NAME;
             $input["keep_networklink"] = 2;
             $input["keep_history"] = 1;
             $input["keep_devices"] = 1;
             $input["keep_infocoms"] = 1;
             $input["keep_enterprises"] = 1;
             $input["keep_contacts"] = 1;
             $input["keep_contracts"] = 1;
             $input["keep_documents"] = 1;
             $id = $transfer->add($input);
         } else {
             $id = 0;
         }
     } else {
         $data = $iterator->next();
         $id = $data['id'];
     }
     return $id;
 }
 /**
  * If rule have found computer or rule give to create computer
  *
  * @param $items_id integer id of the computer found (or 0 if must be created)
  * @param $itemtype value Computer type here
  *
  * @return nothing
  *
  **/
 function rulepassed($items_id, $itemtype)
 {
     global $DB, $PLUGIN_FUSIONINVENTORY_XML, $PF_ESXINVENTORY, $CFG_GLPI;
     PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-rules", "Rule passed : " . $items_id . ", " . $itemtype . "\n");
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $a_computerinventory = $pfFormatconvert->replaceids($this->arrayinventory);
     $entities_id = $_SESSION["plugin_fusioninventory_entity"];
     if ($itemtype == 'Computer') {
         $pfInventoryComputerLib = new PluginFusioninventoryInventoryComputerLib();
         $pfAgent = new PluginFusioninventoryAgent();
         $computer = new Computer();
         if ($items_id == '0') {
             if ($entities_id == -1) {
                 $entities_id = 0;
                 $_SESSION["plugin_fusioninventory_entity"] = 0;
             }
             $_SESSION['glpiactiveentities'] = array($entities_id);
             $_SESSION['glpiactiveentities_string'] = $entities_id;
             $_SESSION['glpiactive_entity'] = $entities_id;
         } else {
             $computer->getFromDB($items_id);
             $a_computerinventory['Computer']['states_id'] = $computer->fields['states_id'];
             $input = array();
             PluginFusioninventoryInventoryComputerInventory::addDefaultStateIfNeeded($input);
             if (isset($input['states_id'])) {
                 $a_computerinventory['Computer']['states_id'] = $input['states_id'];
             }
             if ($entities_id == -1) {
                 $entities_id = $computer->fields['entities_id'];
                 $_SESSION["plugin_fusioninventory_entity"] = $computer->fields['entities_id'];
             }
             $_SESSION['glpiactiveentities'] = array($entities_id);
             $_SESSION['glpiactiveentities_string'] = $entities_id;
             $_SESSION['glpiactive_entity'] = $entities_id;
             if ($computer->fields['entities_id'] != $entities_id) {
                 $pfEntity = new PluginFusioninventoryEntity();
                 $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
                 $moveentity = FALSE;
                 if ($pfEntity->getValue('transfers_id_auto', $computer->fields['entities_id']) > 0) {
                     if (!$pfInventoryComputerComputer->getLock($items_id)) {
                         $moveentity = TRUE;
                     }
                 }
                 if ($moveentity) {
                     $pfEntity = new PluginFusioninventoryEntity();
                     $transfer = new Transfer();
                     $transfer->getFromDB($pfEntity->getValue('transfers_id_auto', $entities_id));
                     $item_to_transfer = array("Computer" => array($items_id => $items_id));
                     $transfer->moveItems($item_to_transfer, $entities_id, $transfer->fields);
                 } else {
                     $_SESSION["plugin_fusioninventory_entity"] = $computer->fields['entities_id'];
                     $_SESSION['glpiactiveentities'] = array($computer->fields['entities_id']);
                     $_SESSION['glpiactiveentities_string'] = $computer->fields['entities_id'];
                     $_SESSION['glpiactive_entity'] = $computer->fields['entities_id'];
                     $entities_id = $computer->fields['entities_id'];
                 }
             }
         }
         $a_computerinventory = $pfFormatconvert->extraCollectInfo($a_computerinventory, $items_id);
         $a_computerinventory = $pfFormatconvert->computerSoftwareTransformation($a_computerinventory, $entities_id);
         $no_history = FALSE;
         // * New
         $setdynamic = 1;
         if ($items_id == '0') {
             $input = array();
             $input['entities_id'] = $entities_id;
             PluginFusioninventoryInventoryComputerInventory::addDefaultStateIfNeeded($input);
             if (isset($input['states_id'])) {
                 $a_computerinventory['Computer']['states_id'] = $input['states_id'];
             } else {
                 $a_computerinventory['Computer']['states_id'] = 0;
             }
             $items_id = $computer->add($input);
             $no_history = TRUE;
             $setdynamic = 0;
         }
         if (isset($_SESSION['plugin_fusioninventory_locations_id'])) {
             $a_computerinventory['Computer']['locations_id'] = $_SESSION['plugin_fusioninventory_locations_id'];
             unset($_SESSION['plugin_fusioninventory_locations_id']);
         }
         $serialized = gzcompress(serialize($a_computerinventory));
         $a_computerinventory['fusioninventorycomputer']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
         if (!$PF_ESXINVENTORY) {
             $pfAgent->setAgentWithComputerid($items_id, $this->device_id, $entities_id);
         }
         $pfConfig = new PluginFusioninventoryConfig();
         $query = "INSERT INTO `glpi_plugin_fusioninventory_dblockinventories`\n            SET `value`='" . $items_id . "'";
         $CFG_GLPI["use_log_in_files"] = FALSE;
         if (!$DB->query($query)) {
             $communication = new PluginFusioninventoryCommunication();
             $communication->setMessage("<?xml version='1.0' encoding='UTF-8'?>\n         <REPLY>\n         <ERROR>ERROR: SAME COMPUTER IS CURRENTLY UPDATED</ERROR>\n         </REPLY>");
             $communication->sendMessage($_SESSION['plugin_fusioninventory_compressmode']);
             exit;
         }
         $CFG_GLPI["use_log_in_files"] = TRUE;
         // * For benchs
         //$start = microtime(TRUE);
         PluginFusioninventoryInventoryComputerStat::increment();
         $pfInventoryComputerLib->updateComputer($a_computerinventory, $items_id, $no_history, $setdynamic);
         $query = "DELETE FROM `glpi_plugin_fusioninventory_dblockinventories`\n               WHERE `value`='" . $items_id . "'";
         $DB->query($query);
         $plugin = new Plugin();
         if ($plugin->isActivated('monitoring')) {
             Plugin::doOneHook("monitoring", "ReplayRulesForItem", array('Computer', $items_id));
         }
         // * For benchs
         //Toolbox::logInFile("exetime", (microtime(TRUE) - $start)." (".$items_id.")\n".
         //  memory_get_usage()."\n".
         //  memory_get_usage(TRUE)."\n".
         //  memory_get_peak_usage()."\n".
         //  memory_get_peak_usage()."\n");
         if (isset($_SESSION['plugin_fusioninventory_rules_id'])) {
             $pfRulematchedlog = new PluginFusioninventoryRulematchedlog();
             $inputrulelog = array();
             $inputrulelog['date'] = date('Y-m-d H:i:s');
             $inputrulelog['rules_id'] = $_SESSION['plugin_fusioninventory_rules_id'];
             if (isset($_SESSION['plugin_fusioninventory_agents_id'])) {
                 $inputrulelog['plugin_fusioninventory_agents_id'] = $_SESSION['plugin_fusioninventory_agents_id'];
             }
             $inputrulelog['items_id'] = $items_id;
             $inputrulelog['itemtype'] = $itemtype;
             $inputrulelog['method'] = 'inventory';
             $pfRulematchedlog->add($inputrulelog, array(), FALSE);
             $pfRulematchedlog->cleanOlddata($items_id, $itemtype);
             unset($_SESSION['plugin_fusioninventory_rules_id']);
         }
         // Write XML file
         if (!empty($PLUGIN_FUSIONINVENTORY_XML)) {
             PluginFusioninventoryToolbox::writeXML($items_id, $PLUGIN_FUSIONINVENTORY_XML->asXML(), 'computer');
         }
     } else {
         if ($itemtype == 'PluginFusioninventoryUnmanaged') {
             $a_computerinventory = $pfFormatconvert->computerSoftwareTransformation($a_computerinventory, $entities_id);
             $class = new $itemtype();
             if ($items_id == "0") {
                 if ($entities_id == -1) {
                     $entities_id = 0;
                     $_SESSION["plugin_fusioninventory_entity"] = 0;
                 }
                 $input = array();
                 $input['date_mod'] = date("Y-m-d H:i:s");
                 $items_id = $class->add($input);
                 if (isset($_SESSION['plugin_fusioninventory_rules_id'])) {
                     $pfRulematchedlog = new PluginFusioninventoryRulematchedlog();
                     $inputrulelog = array();
                     $inputrulelog['date'] = date('Y-m-d H:i:s');
                     $inputrulelog['rules_id'] = $_SESSION['plugin_fusioninventory_rules_id'];
                     if (isset($_SESSION['plugin_fusioninventory_agents_id'])) {
                         $inputrulelog['plugin_fusioninventory_agents_id'] = $_SESSION['plugin_fusioninventory_agents_id'];
                     }
                     $inputrulelog['items_id'] = $items_id;
                     $inputrulelog['itemtype'] = $itemtype;
                     $inputrulelog['method'] = 'inventory';
                     $pfRulematchedlog->add($inputrulelog);
                     $pfRulematchedlog->cleanOlddata($items_id, $itemtype);
                     unset($_SESSION['plugin_fusioninventory_rules_id']);
                 }
             }
             $class->getFromDB($items_id);
             $_SESSION["plugin_fusioninventory_entity"] = $class->fields['entities_id'];
             $input = array();
             $input['id'] = $class->fields['id'];
             // Write XML file
             if (!empty($PLUGIN_FUSIONINVENTORY_XML)) {
                 PluginFusioninventoryToolbox::writeXML($items_id, $PLUGIN_FUSIONINVENTORY_XML->asXML(), 'PluginFusioninventoryUnmanaged');
             }
             if (isset($a_computerinventory['Computer']['name'])) {
                 $input['name'] = $a_computerinventory['Computer']['name'];
             }
             $input['item_type'] = "Computer";
             if (isset($a_computerinventory['Computer']['domains_id'])) {
                 $input['domain'] = $a_computerinventory['Computer']['domains_id'];
             }
             if (isset($a_computerinventory['Computer']['serial'])) {
                 $input['serial'] = $a_computerinventory['Computer']['serial'];
             }
             $class->update($input);
         }
     }
 }
Example #27
0
 /**
  * Create a valid test charge.
  */
 protected static function createTestTransfer(array $attributes = array())
 {
     self::authorizeFromEnv();
     $recipient = self::createTestRecipient();
     return Transfer::create($attributes + array('amount' => 2000, 'currency' => 'usd', 'description' => 'Transfer to test@example.com', 'recipient' => $recipient->id));
 }
Example #28
0
 /**
  *  @see CommonGLPI::getMenuContent()
  *
  *  @since version 0.85
  **/
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     if (Session::haveRight("rule_ldap", READ) || Session::haveRight("rule_ocs", READ) || Session::haveRight("entity_rule_ticket", READ) || Session::haveRight("rule_softwarecategories", READ) || Session::haveRight("rule_mailcollector", READ)) {
         $menu['rule']['title'] = static::getTypeName(Session::getPluralNumber());
         $menu['rule']['page'] = static::getSearchURL(false);
         foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) {
             $rulecollection = new $rulecollectionclass();
             if ($rulecollection->canList()) {
                 $ruleclassname = $rulecollection->getRuleClassName();
                 $menu['rule']['options'][$rulecollection->menu_option]['title'] = $rulecollection->getRuleClass()->getTitle();
                 $menu['rule']['options'][$rulecollection->menu_option]['page'] = Toolbox::getItemTypeSearchURL($ruleclassname, false);
                 $menu['rule']['options'][$rulecollection->menu_option]['links']['search'] = Toolbox::getItemTypeSearchURL($ruleclassname, false);
                 if ($rulecollection->canCreate()) {
                     $menu['rule']['options'][$rulecollection->menu_option]['links']['add'] = Toolbox::getItemTypeFormURL($ruleclassname, false);
                 }
             }
         }
     }
     if (Transfer::canView() && Session::isMultiEntitiesMode()) {
         $menu['rule']['title'] = static::getTypeName(Session::getPluralNumber());
         $menu['rule']['page'] = static::getSearchURL(false);
         $menu['rule']['options']['transfer']['title'] = __('Transfer');
         $menu['rule']['options']['transfer']['page'] = "/front/transfer.php";
         $menu['rule']['options']['transfer']['links']['search'] = "/front/transfer.php";
         if (Session::haveRightsOr("transfer", array(CREATE, UPDATE))) {
             $menu['rule']['options']['transfer']['links']['summary'] = "/front/transfer.action.php";
             $menu['rule']['options']['transfer']['links']['add'] = "/front/transfer.form.php";
         }
     }
     if (Session::haveRight("rule_dictionnary_dropdown", READ) || Session::haveRight("rule_dictionnary_software", READ) || Session::haveRight("rule_dictionnary_printer", READ)) {
         $menu['dictionnary']['title'] = _n('Dictionary', 'Dictionaries', Session::getPluralNumber());
         $menu['dictionnary']['shortcut'] = '';
         $menu['dictionnary']['page'] = '/front/dictionnary.php';
         $menu['dictionnary']['options']['manufacturers']['title'] = _n('Manufacturer', 'Manufacturers', Session::getPluralNumber());
         $menu['dictionnary']['options']['manufacturers']['page'] = '/front/ruledictionnarymanufacturer.php';
         $menu['dictionnary']['options']['manufacturers']['links']['search'] = '/front/ruledictionnarymanufacturer.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['manufacturers']['links']['add'] = '/front/ruledictionnarymanufacturer.form.php';
         }
         $menu['dictionnary']['options']['software']['title'] = _n('Software', 'Software', Session::getPluralNumber());
         $menu['dictionnary']['options']['software']['page'] = '/front/ruledictionnarysoftware.php';
         $menu['dictionnary']['options']['software']['links']['search'] = '/front/ruledictionnarysoftware.php';
         if (RuleDictionnarySoftware::canCreate()) {
             $menu['dictionnary']['options']['software']['links']['add'] = '/front/ruledictionnarysoftware.form.php';
         }
         $menu['dictionnary']['options']['model.computer']['title'] = _n('Computer model', 'Computer models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.computer']['page'] = '/front/ruledictionnarycomputermodel.php';
         $menu['dictionnary']['options']['model.computer']['links']['search'] = '/front/ruledictionnarycomputermodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.computer']['links']['add'] = '/front/ruledictionnarycomputermodel.form.php';
         }
         $menu['dictionnary']['options']['model.monitor']['title'] = _n('Monitor model', 'Monitor models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.monitor']['page'] = '/front/ruledictionnarymonitormodel.php';
         $menu['dictionnary']['options']['model.monitor']['links']['search'] = '/front/ruledictionnarymonitormodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.monitor']['links']['add'] = '/front/ruledictionnarymonitormodel.form.php';
         }
         $menu['dictionnary']['options']['model.printer']['title'] = _n('Printer model', 'Printer models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.printer']['page'] = '/front/ruledictionnaryprintermodel.php';
         $menu['dictionnary']['options']['model.printer']['links']['search'] = '/front/ruledictionnaryprintermodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.printer']['links']['add'] = '/front/ruledictionnaryprintermodel.form.php';
         }
         $menu['dictionnary']['options']['model.peripheral']['title'] = _n('Peripheral model', 'Peripheral models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.peripheral']['page'] = '/front/ruledictionnaryperipheralmodel.php';
         $menu['dictionnary']['options']['model.peripheral']['links']['search'] = '/front/ruledictionnaryperipheralmodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.peripheral']['links']['add'] = '/front/ruledictionnaryperipheralmodel.form.php';
         }
         $menu['dictionnary']['options']['model.networking']['title'] = _n('Networking equipment model', 'Networking equipment models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.networking']['page'] = '/front/ruledictionnarynetworkequipmentmodel.php';
         $menu['dictionnary']['options']['model.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmentmodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmentmodel.form.php';
         }
         $menu['dictionnary']['options']['model.phone']['title'] = _n('Phone model', 'Phone models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.phone']['page'] = '/front/ruledictionnaryphonemodel.php';
         $menu['dictionnary']['options']['model.phone']['links']['search'] = '/front/ruledictionnaryphonemodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.phone']['links']['add'] = '/front/ruledictionnaryphonemodel.form.php';
         }
         $menu['dictionnary']['options']['type.computer']['title'] = _n('Computer type', 'Computer types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.computer']['page'] = '/front/ruledictionnarycomputertype.php';
         $menu['dictionnary']['options']['type.computer']['links']['search'] = '/front/ruledictionnarycomputertype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.computer']['links']['add'] = '/front/ruledictionnarycomputertype.form.php';
         }
         $menu['dictionnary']['options']['type.monitor']['title'] = _n('Monitor type', 'Monitors types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.monitor']['page'] = '/front/ruledictionnarymonitortype.php';
         $menu['dictionnary']['options']['type.monitor']['links']['search'] = '/front/ruledictionnarymonitortype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.monitor']['links']['add'] = '/front/ruledictionnarymonitortype.form.php';
         }
         $menu['dictionnary']['options']['type.printer']['title'] = _n('Printer type', 'Printer types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.printer']['page'] = '/front/ruledictionnaryprintertype.php';
         $menu['dictionnary']['options']['type.printer']['links']['search'] = '/front/ruledictionnaryprintertype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.printer']['links']['add'] = '/front/ruledictionnaryprintertype.form.php';
         }
         $menu['dictionnary']['options']['type.peripheral']['title'] = _n('Peripheral type', 'Peripheral types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.peripheral']['page'] = '/front/ruledictionnaryperipheraltype.php';
         $menu['dictionnary']['options']['type.peripheral']['links']['search'] = '/front/ruledictionnaryperipheraltype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.peripheral']['links']['add'] = '/front/ruledictionnaryperipheraltype.form.php';
         }
         $menu['dictionnary']['options']['type.networking']['title'] = _n('Networking equipment type', 'Networking equipment types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.networking']['page'] = '/front/ruledictionnarynetworkequipmenttype.php';
         $menu['dictionnary']['options']['type.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmenttype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmenttype.form.php';
         }
         $menu['dictionnary']['options']['type.phone']['title'] = _n('Phone type', 'Phone types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.phone']['page'] = '/front/ruledictionnaryphonetype.php';
         $menu['dictionnary']['options']['type.phone']['links']['search'] = '/front/ruledictionnaryphonetype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.phone']['links']['add'] = '/front/ruledictionnaryphonetype.form.php';
         }
         $menu['dictionnary']['options']['os']['title'] = __('Operating system');
         $menu['dictionnary']['options']['os']['page'] = '/front/ruledictionnaryoperatingsystem.php';
         $menu['dictionnary']['options']['os']['links']['search'] = '/front/ruledictionnaryoperatingsystem.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os']['links']['add'] = '/front/ruledictionnaryoperatingsystem.form.php';
         }
         $menu['dictionnary']['options']['os_sp']['title'] = __('Service pack');
         $menu['dictionnary']['options']['os_sp']['page'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
         $menu['dictionnary']['options']['os_sp']['links']['search'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os_sp']['links']['add'] = '/front/ruledictionnaryoperatingsystemservicepack.form.php';
         }
         $menu['dictionnary']['options']['os_version']['title'] = __('Version of the operating system');
         $menu['dictionnary']['options']['os_version']['page'] = '/front/ruledictionnaryoperatingsystemversion.php';
         $menu['dictionnary']['options']['os_version']['links']['search'] = '/front/ruledictionnaryoperatingsystemversion.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os_version']['links']['add'] = '/front/ruledictionnaryoperatingsystemversion.form.php';
         }
         $menu['dictionnary']['options']['printer']['title'] = _n('Printer', 'Printers', Session::getPluralNumber());
         $menu['dictionnary']['options']['printer']['page'] = '/front/ruledictionnaryprinter.php';
         $menu['dictionnary']['options']['printer']['links']['search'] = '/front/ruledictionnaryprinter.php';
         if (RuleDictionnaryPrinter::canCreate()) {
             $menu['dictionnary']['options']['printer']['links']['add'] = '/front/ruledictionnaryprinter.form.php';
         }
     }
     if (count($menu)) {
         $menu['is_multi_entries'] = true;
         return $menu;
     }
     return false;
 }
Example #29
0
 function showTransferList()
 {
     global $DB, $CFG_GLPI;
     if (isset($_SESSION['glpitransfer_list']) && count($_SESSION['glpitransfer_list'])) {
         echo "<div class='center b'>" . __('You can continue to add elements to be transferred or execute the transfer now');
         echo "<br>" . __('Think of making a backup before transferring items.') . "</div>";
         echo "<table class='tab_cadre_fixe' >";
         echo '<tr><th>' . __('Items to transfer') . '</th><th>' . __('Transfer mode') . "&nbsp;";
         $rand = Transfer::dropdown(array('name' => 'id', 'comments' => false, 'toupdate' => array('value_fieldname' => 'id', 'to_update' => "transfer_form", 'url' => $CFG_GLPI["root_doc"] . "/ajax/transfers.php")));
         echo '</th></tr>';
         echo "<tr><td class='tab_bg_1 top'>";
         foreach ($_SESSION['glpitransfer_list'] as $itemtype => $tab) {
             if (count($tab)) {
                 $table = getTableForItemType($itemtype);
                 $query = "SELECT `{$table}`.`id`,\n                                 `{$table}`.`name`,\n                                 `glpi_entities`.`completename` AS locname,\n                                 `glpi_entities`.`id` AS entID\n                          FROM `{$table}`\n                          LEFT JOIN `glpi_entities`\n                               ON (`{$table}`.`entities_id` = `glpi_entities`.`id`)\n                          WHERE `{$table}`.`id` IN " . $this->createSearchConditionUsingArray($tab) . "\n                         ORDER BY locname, `{$table}`.`name`";
                 $entID = -1;
                 if (!($item = getItemForItemtype($itemtype))) {
                     continue;
                 }
                 if ($result = $DB->query($query)) {
                     if ($DB->numrows($result)) {
                         echo '<h3>' . $item->getTypeName() . '</h3>';
                         while ($data = $DB->fetch_assoc($result)) {
                             if ($entID != $data['entID']) {
                                 if ($entID != -1) {
                                     echo '<br>';
                                 }
                                 $entID = $data['entID'];
                                 echo "<span class='b spaced'>" . $data['locname'] . "</span><br>";
                             }
                             echo ($data['name'] ? $data['name'] : "(" . $data['id'] . ")") . "<br>";
                         }
                     }
                 }
             }
         }
         echo "</td><td class='tab_bg_2 top'>";
         if (countElementsInTable('glpi_transfers') == 0) {
             _e('No item found');
         } else {
             $params = array('id' => '__VALUE__');
             Ajax::updateItemOnSelectEvent("dropdown_id{$rand}", "transfer_form", $CFG_GLPI["root_doc"] . "/ajax/transfers.php", $params);
         }
         echo "<div class='center' id='transfer_form'><br>";
         Html::showSimpleForm($CFG_GLPI["root_doc"] . "/front/transfer.action.php", 'clear', __('To empty the list of elements to be transferred'));
         echo "</div>";
         echo '</td></tr>';
         echo '</table>';
     } else {
         _e('No selected element or badly defined operation');
     }
 }
Example #30
0
 private function log($source, $destination, $amount)
 {
     Transfer::create(array('source_account_number' => $source->d()->number, 'destination_account_number' => $destination->d()->number, 'amount' => $amount, 'user_id' => USER_ID, 'created' => new DateTime()));
 }